Skip to content

Commit

Permalink
fixup! Add option to not revoke token
Browse files Browse the repository at this point in the history
  • Loading branch information
tibdex committed Sep 19, 2023
1 parent 6eb69dd commit bdc651a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
node-version: 20
cache: npm
- run: npm ci
# - run: npm run typecheck
- run: npm run typecheck
- run: npm run build
# Optional integration test of the action using a dedicated GitHub App.
- id: create_token
Expand All @@ -25,6 +25,7 @@ jobs:
# The only required permission is `Repository permissions > Metadata: Read-only`.
app_id: ${{ vars.TEST_GITHUB_APP_ID }}
private_key: ${{ secrets.TEST_GITHUB_APP_PRIVATE_KEY }}
revoke: false
- if: ${{ steps.create_token.outcome != 'skipped' }}
run: node --eval "assert('${{ steps.create_token.outputs.token }}'.length > 0);"
# - run: npm run prettier -- --check
- run: npm run prettier -- --check
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ runs:
using: node20
main: dist/main/index.js
post: dist/post/index.js
post-if: inputs.revoke == 'true'
branding:
icon: unlock
color: gray-dark
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dist"
],
"scripts": {
"build": "npm run build:main",
"build": "npm run build:main && npm run build:post",
"build:main": "npm run compile -- --out ./dist/main src/main.ts ",
"build:post": "npm run compile -- --out ./dist/post src/post.ts",
"compile": "ncc build --minify --no-cache --target es2022 --v8-cache",
Expand Down
12 changes: 10 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { info, saveState, setOutput, setSecret } from "@actions/core";

import { createInstallationAccessToken } from "./create-installation-access-token.js";
import { parseOptions } from "./parse-options.js";
import { run } from "./run.js";
import { getInput } from "@actions/core";
import { tokenKey } from "./state.js";

await run(async () => {
console.log(JSON.stringify({value: JSON.parse(getInput("revoke"))}));
const options = parseOptions();
const token = await createInstallationAccessToken(options);
setSecret(token);
saveState(tokenKey, token);
setOutput("token", token);
info("Token created successfully");
});
7 changes: 6 additions & 1 deletion src/post.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { getState, info } from "@actions/core";
import { getInput, getState, info } from "@actions/core";

import { revokeInstallationAccessToken } from "./revoke-installation-access-token.js";
import { run } from "./run.js";
import { tokenKey } from "./state.js";

await run(async () => {
if (!JSON.parse(getInput("revoke"))) {
info("Token revocation skipped");
return;
}

const token = getState(tokenKey);
if (!token) {
info("No token to revoke");
Expand Down

0 comments on commit bdc651a

Please sign in to comment.