Skip to content

Commit 1d910c8

Browse files
authored
Merge pull request #707 from crazy-max/gh-runtime-token-info
Log GitHub Actions runtime token access controls
2 parents c40bf0f + f9ccca0 commit 1d910c8

File tree

7 files changed

+55
-5
lines changed

7 files changed

+55
-5
lines changed

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@actions/github": "^5.1.1",
3434
"csv-parse": "^5.3.3",
3535
"handlebars": "^4.7.7",
36+
"jwt-decode": "^3.1.2",
3637
"semver": "^7.3.7",
3738
"tmp": "^0.2.1"
3839
},

src/github.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import jwt_decode, {JwtPayload} from 'jwt-decode';
2+
3+
interface Jwt extends JwtPayload {
4+
ac?: string;
5+
}
6+
7+
export const parseRuntimeToken = (token: string): Jwt => {
8+
return jwt_decode<Jwt>(token);
9+
};

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from 'fs';
22
import * as buildx from './buildx';
33
import * as context from './context';
44
import * as docker from './docker';
5+
import * as github from './github';
56
import * as stateHelper from './state-helper';
67
import * as core from '@actions/core';
78
import * as exec from '@actions/exec';
@@ -14,6 +15,15 @@ async function run(): Promise<void> {
1415
// standalone if docker cli not available
1516
const standalone = !(await docker.isAvailable());
1617

18+
await core.group(`GitHub Actions runtime token access controls`, async () => {
19+
const actionsRuntimeToken = process.env['ACTIONS_RUNTIME_TOKEN'];
20+
if (actionsRuntimeToken) {
21+
core.info(JSON.stringify(JSON.parse(github.parseRuntimeToken(actionsRuntimeToken).ac as string), undefined, 2));
22+
} else {
23+
core.info(`ACTIONS_RUNTIME_TOKEN not set`);
24+
}
25+
});
26+
1727
core.startGroup(`Docker info`);
1828
if (standalone) {
1929
core.info(`Docker info skipped in standalone mode`);

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,11 @@ json5@2.x, json5@^2.1.2:
28282828
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
28292829
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
28302830

2831+
jwt-decode@^3.1.2:
2832+
version "3.1.2"
2833+
resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59"
2834+
integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==
2835+
28312836
kleur@^3.0.3:
28322837
version "3.0.3"
28332838
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"

0 commit comments

Comments
 (0)