Skip to content

Commit

Permalink
Make some improvements (tibdex#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibdex authored Sep 5, 2020
1 parent fbd4e48 commit c194166
Show file tree
Hide file tree
Showing 4 changed files with 737 additions and 512 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

module.exports = {
// eslint-disable-next-line unicorn/prevent-abbreviations
env: {
es6: true,
},
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-app-token",
"version": "1.0.2",
"version": "1.1.0",
"license": "MIT",
"files": [
"action.yml",
Expand All @@ -15,26 +15,26 @@
"prettier": "prettier --ignore-path .gitignore \"./**/*.{js,json,md,ts,yml}\""
},
"devDependencies": {
"@actions/core": "^1.2.3",
"@actions/github": "^2.1.1",
"@octokit/app": "^4.2.0",
"@actions/core": "^1.2.5",
"@actions/github": "^4.0.0",
"@octokit/app": "^4.2.1",
"@types/is-base64": "^1.1.0",
"@types/node": "^10.0.3",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"@zeit/ncc": "^0.22.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-xo": "^0.29.1",
"eslint-config-xo-typescript": "^0.27.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-sort-destructure-keys": "^1.3.3",
"eslint-plugin-typescript-sort-keys": "^0.8.0",
"eslint-plugin-unicorn": "^18.0.1",
"@types/node": "^14.6.4",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@vercel/ncc": "^0.24.0",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-config-xo": "^0.32.1",
"eslint-config-xo-typescript": "^0.32.0",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-sort-destructure-keys": "^1.3.5",
"eslint-plugin-typescript-sort-keys": "^1.3.0",
"eslint-plugin-unicorn": "^21.0.0",
"is-base64": "^1.1.0",
"prettier": "^2.0.4",
"promise-retry": "^1.1.1",
"typescript": "^3.8.3"
"prettier": "^2.1.1",
"promise-retry": "^2.0.1",
"typescript": "^4.0.2"
}
}
22 changes: 14 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core";
import { context, GitHub } from "@actions/github";
import {
error as logError,
getInput,
info,
setFailed,
setOutput,
setSecret,
} from "@actions/core";
import { context, getOctokit } from "@actions/github";
import { App } from "@octokit/app";
import isBase64 from "is-base64";

Expand All @@ -12,21 +19,20 @@ const run = async () => {
: privateKeyInput;
const app = new App({ id, privateKey });
const jwt = app.getSignedJsonWebToken();
const github = new GitHub(jwt);
const octokit = getOctokit(jwt);
const {
data: { id: installationId },
} = await github.apps.getRepoInstallation(context.repo);
} = await octokit.apps.getRepoInstallation(context.repo);
const token = await app.getInstallationAccessToken({
installationId,
});
setSecret(token);
setOutput("token", token);
info("Token generated successfully!");
} catch (error) {
if (error instanceof Error) {
setFailed(error.message);
}
logError(error);
setFailed(error.message);
}
};

run();
void run();
Loading

0 comments on commit c194166

Please sign in to comment.