github: throw if runtime token invalid

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-20 10:14:11 +01:00
parent 1098847fe7
commit c3aa7f205d
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
2 changed files with 5 additions and 13 deletions

View file

@ -59,12 +59,10 @@ export class GitHub {
try {
jwt = GitHub.actionsRuntimeToken;
} catch (e) {
core.warning(`Cannot parse Actions Runtime Token: ${e.message}`);
return;
throw new Error(`Cannot parse GitHub Actions Runtime Token: ${e.message}`);
}
if (!jwt) {
core.warning(`ACTIONS_RUNTIME_TOKEN not set`);
return;
throw new Error(`ACTIONS_RUNTIME_TOKEN not set`);
}
try {
<Array<GitHubActionsRuntimeTokenAC>>JSON.parse(`${jwt.ac}`).forEach(ac => {
@ -85,7 +83,7 @@ export class GitHub {
core.info(`${ac.Scope}: ${permission}`);
});
} catch (e) {
core.warning(`Cannot parse Actions Runtime Token Access Controls: ${e.message}`);
throw new Error(`Cannot parse GitHub Actions Runtime Token ACs: ${e.message}`);
}
}
}