Fix octokit definition object

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-05-25 02:07:25 +02:00
parent e5c54f2159
commit 28d7c8bbcd
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
6 changed files with 586 additions and 298 deletions

View file

@ -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'));
}
);

View file

@ -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'));
}
);

851
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

View file

@ -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({
...github.context.repo
});
if (!repo?.data) {
throw new Error('Cannot get GitHub repository');
}
return repo.data;
return github
.getOctokit(token)
.rest.repos.get({
...github.context.repo
})
.then(response => response.data as ReposGetResponseData);
}

View file

@ -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}`);

View file

@ -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;