mirror of
https://gitea.com/docker/metadata-action.git
synced 2024-11-22 12:09:32 +01:00
Fix octokit definition object
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e5c54f2159
commit
28d7c8bbcd
6 changed files with 586 additions and 298 deletions
|
@ -1,10 +1,9 @@
|
|||
import * as path from 'path';
|
||||
import * as github from '../src/github';
|
||||
import {ReposGetResponseData} from '@octokit/types';
|
||||
|
||||
jest.spyOn(github, 'repo').mockImplementation(
|
||||
(): Promise<ReposGetResponseData> => {
|
||||
return <Promise<ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
||||
(): Promise<github.ReposGetResponseData> => {
|
||||
return <Promise<github.ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@ import {getInputs, Inputs} from '../src/context';
|
|||
import * as github from '../src/github';
|
||||
import {Meta, Version} from '../src/meta';
|
||||
import {Context} from '@actions/github/lib/context';
|
||||
import {ReposGetResponseData} from '@octokit/types';
|
||||
|
||||
jest.spyOn(github, 'repo').mockImplementation(
|
||||
(): Promise<ReposGetResponseData> => {
|
||||
return <Promise<ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
||||
(): Promise<github.ReposGetResponseData> => {
|
||||
return <Promise<github.ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
837
dist/index.js
generated
vendored
837
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -1,18 +1,18 @@
|
|||
import * as github from '@actions/github';
|
||||
import {Context} from '@actions/github/lib/context';
|
||||
import {ReposGetResponseData} from '@octokit/types';
|
||||
import {components as OctoOpenApiTypes} from '@octokit/openapi-types';
|
||||
|
||||
export type ReposGetResponseData = OctoOpenApiTypes['schemas']['repository'];
|
||||
|
||||
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({
|
||||
return github
|
||||
.getOctokit(token)
|
||||
.rest.repos.get({
|
||||
...github.context.repo
|
||||
});
|
||||
if (!repo?.data) {
|
||||
throw new Error('Cannot get GitHub repository');
|
||||
}
|
||||
return repo.data;
|
||||
})
|
||||
.then(response => response.data as ReposGetResponseData);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import * as github from './github';
|
|||
import {Meta, Version} from './meta';
|
||||
import * as core from '@actions/core';
|
||||
import {Context} from '@actions/github/lib/context';
|
||||
import {ReposGetResponseData} from '@octokit/types';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
|
@ -14,7 +13,7 @@ async function run() {
|
|||
}
|
||||
|
||||
const context: Context = github.context();
|
||||
const repo: ReposGetResponseData = await github.repo(inputs.githubToken);
|
||||
const repo: github.ReposGetResponseData = await github.repo(inputs.githubToken);
|
||||
core.startGroup(`Context info`);
|
||||
core.info(`eventName: ${context.eventName}`);
|
||||
core.info(`sha: ${context.sha}`);
|
||||
|
|
|
@ -4,11 +4,11 @@ import * as path from 'path';
|
|||
import moment from 'moment';
|
||||
import * as semver from 'semver';
|
||||
import {Inputs, tmpDir} from './context';
|
||||
import {ReposGetResponseData} from './github';
|
||||
import * as tcl from './tag';
|
||||
import * as fcl from './flavor';
|
||||
import * as core from '@actions/core';
|
||||
import {Context} from '@actions/github/lib/context';
|
||||
import {ReposGetResponseData} from '@octokit/types';
|
||||
|
||||
export interface Version {
|
||||
main: string | undefined;
|
||||
|
|
Loading…
Reference in a new issue