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

Commit c194166

Browse files
authored
Make some improvements (#5)
1 parent fbd4e48 commit c194166

File tree

4 files changed

+737
-512
lines changed

4 files changed

+737
-512
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22

33
module.exports = {
4-
// eslint-disable-next-line unicorn/prevent-abbreviations
54
env: {
65
es6: true,
76
},

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-app-token",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"license": "MIT",
55
"files": [
66
"action.yml",
@@ -15,26 +15,26 @@
1515
"prettier": "prettier --ignore-path .gitignore \"./**/*.{js,json,md,ts,yml}\""
1616
},
1717
"devDependencies": {
18-
"@actions/core": "^1.2.3",
19-
"@actions/github": "^2.1.1",
20-
"@octokit/app": "^4.2.0",
18+
"@actions/core": "^1.2.5",
19+
"@actions/github": "^4.0.0",
20+
"@octokit/app": "^4.2.1",
2121
"@types/is-base64": "^1.1.0",
22-
"@types/node": "^10.0.3",
23-
"@typescript-eslint/eslint-plugin": "^2.27.0",
24-
"@typescript-eslint/parser": "^2.27.0",
25-
"@zeit/ncc": "^0.22.1",
26-
"eslint": "^6.8.0",
27-
"eslint-config-prettier": "^6.10.1",
28-
"eslint-config-xo": "^0.29.1",
29-
"eslint-config-xo-typescript": "^0.27.0",
30-
"eslint-import-resolver-typescript": "^2.0.0",
31-
"eslint-plugin-import": "^2.20.2",
32-
"eslint-plugin-sort-destructure-keys": "^1.3.3",
33-
"eslint-plugin-typescript-sort-keys": "^0.8.0",
34-
"eslint-plugin-unicorn": "^18.0.1",
22+
"@types/node": "^14.6.4",
23+
"@typescript-eslint/eslint-plugin": "^4.0.1",
24+
"@typescript-eslint/parser": "^4.0.1",
25+
"@vercel/ncc": "^0.24.0",
26+
"eslint": "^7.8.1",
27+
"eslint-config-prettier": "^6.11.0",
28+
"eslint-config-xo": "^0.32.1",
29+
"eslint-config-xo-typescript": "^0.32.0",
30+
"eslint-import-resolver-typescript": "^2.3.0",
31+
"eslint-plugin-import": "^2.22.0",
32+
"eslint-plugin-sort-destructure-keys": "^1.3.5",
33+
"eslint-plugin-typescript-sort-keys": "^1.3.0",
34+
"eslint-plugin-unicorn": "^21.0.0",
3535
"is-base64": "^1.1.0",
36-
"prettier": "^2.0.4",
37-
"promise-retry": "^1.1.1",
38-
"typescript": "^3.8.3"
36+
"prettier": "^2.1.1",
37+
"promise-retry": "^2.0.1",
38+
"typescript": "^4.0.2"
3939
}
4040
}

src/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core";
2-
import { context, GitHub } from "@actions/github";
1+
import {
2+
error as logError,
3+
getInput,
4+
info,
5+
setFailed,
6+
setOutput,
7+
setSecret,
8+
} from "@actions/core";
9+
import { context, getOctokit } from "@actions/github";
310
import { App } from "@octokit/app";
411
import isBase64 from "is-base64";
512

@@ -12,21 +19,20 @@ const run = async () => {
1219
: privateKeyInput;
1320
const app = new App({ id, privateKey });
1421
const jwt = app.getSignedJsonWebToken();
15-
const github = new GitHub(jwt);
22+
const octokit = getOctokit(jwt);
1623
const {
1724
data: { id: installationId },
18-
} = await github.apps.getRepoInstallation(context.repo);
25+
} = await octokit.apps.getRepoInstallation(context.repo);
1926
const token = await app.getInstallationAccessToken({
2027
installationId,
2128
});
2229
setSecret(token);
2330
setOutput("token", token);
2431
info("Token generated successfully!");
2532
} catch (error) {
26-
if (error instanceof Error) {
27-
setFailed(error.message);
28-
}
33+
logError(error);
34+
setFailed(error.message);
2935
}
3036
};
3137

32-
run();
38+
void run();

0 commit comments

Comments
 (0)