forked from peter-murray/workflow-application-token-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.js
33 lines (29 loc) · 1.1 KB
/
post.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const core = require('@actions/core')
, githubApplication = require('./lib/github-application')
;
async function revokeToken() {
const token = core.getState('token');
if (!token) {
core.info(`There is no valid token stored in the action state, nothing to revoke.`);
return;
}
try {
const revokeToken = core.getBooleanInput('revoke_token');
if (revokeToken) {
core.info(`GitHub Application token revocation being performed...`);
const baseUrl = core.getInput('github_api_base_url');
const proxy = core.getInput('https_proxy')
const revoked = await githubApplication.revokeAccessToken(token, baseUrl, proxy);
if (revoked) {
core.info(` token has been revoked.`)
} else {
throw new Error('Failed to revoke the application token, see logs for more information.');
}
} else {
core.info(`GitHub Application revocation in post action step was skipped. Token will expired based on time set on the token.`);
}
} catch (err) {
core.setFailed(`Failed to revoke GitHub Application token; ${err.message}`);
}
}
revokeToken();