mirror of
https://code.forgejo.org/docker/actions-toolkit.git
synced 2025-06-24 06:38:23 -04:00
commit
c617b15f70
2 changed files with 51 additions and 33 deletions
|
@ -31,27 +31,30 @@ export interface GitHubOpts {
|
|||
}
|
||||
|
||||
export class GitHub {
|
||||
public static readonly serverURL: string = process.env.GITHUB_SERVER_URL || 'https://github.com';
|
||||
public readonly octokit: InstanceType<typeof Octokit>;
|
||||
|
||||
constructor(opts?: GitHubOpts) {
|
||||
this.octokit = github.getOctokit(`${opts?.token}`);
|
||||
}
|
||||
|
||||
get context(): Context {
|
||||
return github.context;
|
||||
}
|
||||
|
||||
get serverURL(): string {
|
||||
return process.env.GITHUB_SERVER_URL || 'https://github.com';
|
||||
}
|
||||
|
||||
get actionsRuntimeToken(): GitHubActionsRuntimeToken {
|
||||
const token = process.env['ACTIONS_RUNTIME_TOKEN'] || '';
|
||||
return token ? jwt_decode<GitHubActionsRuntimeToken>(token) : {};
|
||||
}
|
||||
|
||||
public repoData(): Promise<GitHubRepo> {
|
||||
return this.octokit.rest.repos.get({...github.context.repo}).then(response => response.data as GitHubRepo);
|
||||
}
|
||||
|
||||
static get context(): Context {
|
||||
return github.context;
|
||||
}
|
||||
|
||||
static get serverURL(): string {
|
||||
return process.env.GITHUB_SERVER_URL || 'https://github.com';
|
||||
}
|
||||
|
||||
static get apiURL(): string {
|
||||
return process.env.GITHUB_API_URL || 'https://api.github.com';
|
||||
}
|
||||
|
||||
static get actionsRuntimeToken(): GitHubActionsRuntimeToken {
|
||||
const token = process.env['ACTIONS_RUNTIME_TOKEN'] || '';
|
||||
return token ? jwt_decode<GitHubActionsRuntimeToken>(token) : {};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue