3
0
Fork 0
mirror of https://gitea.com/docker/metadata-action.git synced 2024-11-22 20:19:33 +01:00
docker-metadata/src/github.ts

19 lines
508 B
TypeScript
Raw Permalink Normal View History

2020-10-25 02:25:23 +01:00
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;
}