mirror of
https://github.com/docker/metadata-action.git
synced 2024-12-23 09:05:29 +00:00
19 lines
508 B
TypeScript
19 lines
508 B
TypeScript
|
import * as github from '@actions/github';
|
||
|
import {Context} from '@actions/github/lib/context';
|
||
|
import {ReposGetResponseData} from '@octokit/types';
|
||
|
|
||
|
export function context(): Context {
|
||
|
return github.context;
|
||
|
}
|
||
|
|
||
|
export async function repo(token: string): Promise<ReposGetResponseData> {
|
||
|
const octokit = github.getOctokit(token);
|
||
|
const repo = await octokit.repos.get({
|
||
|
...github.context.repo
|
||
|
});
|
||
|
if (!repo?.data) {
|
||
|
throw new Error('Cannot get GitHub repository');
|
||
|
}
|
||
|
return repo.data;
|
||
|
}
|