test: githubActionsRuntimeToken

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-30 03:08:12 +01:00
parent 85ef93202e
commit 039779492c
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
3 changed files with 32 additions and 3 deletions

View file

@ -6,7 +6,7 @@ import {Context} from '@actions/github/lib/context';
export type GitHubRepo = OctoOpenApiTypes['schemas']['repository'];
export interface GitHubRuntimeToken extends JwtPayload {
export interface GitHubActionsRuntimeToken extends JwtPayload {
ac?: string;
}
@ -30,8 +30,9 @@ export class GitHub {
return process.env.GITHUB_SERVER_URL || 'https://github.com';
}
get runtimeToken(): GitHubRuntimeToken {
return jwt_decode<GitHubRuntimeToken>(`${process.env['ACTIONS_RUNTIME_TOKEN']}`);
get actionsRuntimeToken(): GitHubActionsRuntimeToken {
const token = process.env['ACTIONS_RUNTIME_TOKEN'] || '';
return token ? jwt_decode<GitHubActionsRuntimeToken>(token) : {};
}
public repoData(): Promise<GitHubRepo> {