Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit b0ce803

Browse files
committed
Upgrade deps
1 parent c3ff703 commit b0ce803

File tree

8 files changed

+1065
-628
lines changed

8 files changed

+1065
-628
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The MIT License (MIT)
2-
Copyright (c) 2022 Thibault Derousseaux <[email protected]>
2+
Copyright (c) 2023 Thibault Derousseaux <[email protected]>
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-app-token",
3-
"version": "1.7.0",
3+
"version": "1.8.0",
44
"license": "MIT",
55
"type": "module",
66
"files": [
@@ -9,31 +9,31 @@
99
],
1010
"scripts": {
1111
"prebuild": "tsc --build",
12-
"build": "ncc build src/index.ts --minify --target es2021 --v8-cache",
12+
"build": "ncc build src/index.ts --minify --target es2021 --v8-cache",
1313
"prettier": "prettier --ignore-path .gitignore \"./**/*.{cjs,js,json,md,ts,yml}\"",
1414
"xo": "xo"
1515
},
1616
"dependencies": {
1717
"@actions/core": "^1.10.0",
1818
"@actions/github": "^5.1.1",
19-
"@octokit/auth-app": "^4.0.7",
20-
"@octokit/request": "^6.2.2",
19+
"@octokit/auth-app": "^4.0.9",
20+
"@octokit/request": "^6.2.3",
2121
"ensure-error": "^4.0.0",
2222
"is-base64": "^1.1.0"
2323
},
2424
"devDependencies": {
25-
"@types/error-cause": "^1.0.1",
25+
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
2626
"@types/is-base64": "^1.1.1",
2727
"@types/node": "^16.11.26",
28-
"@vercel/ncc": "^0.34.0",
29-
"eslint-config-prettier": "^8.5.0",
30-
"eslint-plugin-import": "^2.26.0",
28+
"@vercel/ncc": "^0.36.1",
29+
"eslint-config-prettier": "^8.6.0",
30+
"eslint-plugin-import": "^2.27.5",
3131
"eslint-plugin-sort-destructure-keys": "^1.4.0",
3232
"eslint-plugin-typescript-sort-keys": "^2.1.0",
33-
"prettier": "^2.7.1",
34-
"prettier-plugin-packagejson": "^2.3.0",
35-
"typescript": "^4.8.4",
36-
"xo": "^0.52.4",
37-
"yarn-deduplicate": "^5.0.0"
33+
"prettier": "^2.8.3",
34+
"prettier-plugin-packagejson": "^2.4.0",
35+
"typescript": "^4.9.4",
36+
"xo": "^0.53.1",
37+
"yarn-deduplicate": "^6.0.1"
3838
}
3939
}

prettier.config.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"use strict";
22

33
module.exports = {
4+
importOrder: ["^node:(.*)$", "<THIRD_PARTY_MODULES>", "^[./]"],
5+
importOrderGroupNamespaceSpecifiers: true,
6+
importOrderSeparation: true,
7+
importOrderSortSpecifiers: true,
48
trailingComma: "all",
59
};

src/fetch-installation-token.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { getOctokit } from "@actions/github";
22
import { createAppAuth } from "@octokit/auth-app";
33
import { request } from "@octokit/request";
4-
import ensureError from "ensure-error";
54

65
export const fetchInstallationToken = async ({
76
appId,
@@ -42,7 +41,7 @@ export const fetchInstallationToken = async ({
4241
} catch (error: unknown) {
4342
throw new Error(
4443
"Could not get repo installation. Is the app installed on this repo?",
45-
{ cause: ensureError(error) },
44+
{ cause: error },
4645
);
4746
}
4847
}
@@ -56,7 +55,7 @@ export const fetchInstallationToken = async ({
5655
return installation.token;
5756
} catch (error: unknown) {
5857
throw new Error("Could not create installation access token.", {
59-
cause: ensureError(error),
58+
cause: error,
6059
});
6160
}
6261
};

src/index.ts

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
11
import { Buffer } from "node:buffer";
2+
23
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core";
34
import ensureError from "ensure-error";
45
import isBase64 from "is-base64";
6+
57
import { fetchInstallationToken } from "./fetch-installation-token.js";
68

7-
const run = async () => {
8-
try {
9-
const appId = getInput("app_id", { required: true });
10-
11-
const installationIdInput = getInput("installation_id");
12-
const installationId = installationIdInput
13-
? Number(installationIdInput)
14-
: undefined;
15-
16-
const permissionsInput = getInput("permissions");
17-
const permissions = permissionsInput
18-
? (JSON.parse(permissionsInput) as Record<string, string>)
19-
: undefined;
20-
21-
const privateKeyInput = getInput("private_key", { required: true });
22-
const privateKey = isBase64(privateKeyInput)
23-
? Buffer.from(privateKeyInput, "base64").toString("utf8")
24-
: privateKeyInput;
25-
26-
const repositoryInput = getInput("repository", { required: true });
27-
const [owner, repo] = repositoryInput.split("/");
28-
29-
const githubApiUrlInput = getInput("github_api_url", { required: true });
30-
const githubApiUrl = new URL(githubApiUrlInput);
31-
32-
const installationToken = await fetchInstallationToken({
33-
appId,
34-
githubApiUrl,
35-
installationId,
36-
owner,
37-
permissions,
38-
privateKey,
39-
repo,
40-
});
41-
42-
setSecret(installationToken);
43-
setOutput("token", installationToken);
44-
info("Token generated successfully!");
45-
} catch (_error: unknown) {
46-
const error = ensureError(_error);
47-
setFailed(error);
48-
}
49-
};
50-
51-
void run();
9+
try {
10+
const appId = getInput("app_id", { required: true });
11+
12+
const installationIdInput = getInput("installation_id");
13+
const installationId = installationIdInput
14+
? Number(installationIdInput)
15+
: undefined;
16+
17+
const permissionsInput = getInput("permissions");
18+
const permissions = permissionsInput
19+
? (JSON.parse(permissionsInput) as Record<string, string>)
20+
: undefined;
21+
22+
const privateKeyInput = getInput("private_key", { required: true });
23+
const privateKey = isBase64(privateKeyInput)
24+
? Buffer.from(privateKeyInput, "base64").toString("utf8")
25+
: privateKeyInput;
26+
27+
const repositoryInput = getInput("repository", { required: true });
28+
const [owner, repo] = repositoryInput.split("/");
29+
30+
const githubApiUrlInput = getInput("github_api_url", { required: true });
31+
const githubApiUrl = new URL(githubApiUrlInput);
32+
33+
const installationToken = await fetchInstallationToken({
34+
appId,
35+
githubApiUrl,
36+
installationId,
37+
owner,
38+
permissions,
39+
privateKey,
40+
repo,
41+
});
42+
43+
setSecret(installationToken);
44+
setOutput("token", installationToken);
45+
info("Token generated successfully!");
46+
} catch (_error: unknown) {
47+
const error = ensureError(_error);
48+
setFailed(error);
49+
}

tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"compilerOptions": {
33
"forceConsistentCasingInFileNames": true,
4-
"module": "nodenext",
5-
"moduleResolution": "nodenext",
4+
"module": "Node16",
5+
"moduleResolution": "Node16",
66
"noEmit": true,
77
"strict": true,
8-
"target": "es2021",
9-
"types": ["node", "error-cause/auto"]
8+
"target": "ES2022",
9+
"types": ["node"]
1010
},
1111
"include": ["src"]
1212
}

xo.config.cjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ module.exports = {
3131
},
3232
],
3333
"import/no-namespace": "error",
34-
"import/order": [
35-
"error",
36-
{
37-
alphabetize: {
38-
caseInsensitive: true,
39-
order: "asc",
40-
},
41-
"newlines-between": "never",
42-
},
43-
],
4434
"no-console": "error",
4535
"object-shorthand": [
4636
"error",
@@ -53,7 +43,6 @@ module.exports = {
5343
caseSensitive: false,
5444
},
5545
],
56-
"sort-imports": ["error", { ignoreDeclarationSort: true }],
5746
"sort-keys": [
5847
"error",
5948
"asc",

0 commit comments

Comments
 (0)