Fix octokit definition object
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e5c54f2159
commit
28d7c8bbcd
|
@ -1,10 +1,9 @@
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as github from '../src/github';
|
import * as github from '../src/github';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
|
||||||
|
|
||||||
jest.spyOn(github, 'repo').mockImplementation(
|
jest.spyOn(github, 'repo').mockImplementation(
|
||||||
(): Promise<ReposGetResponseData> => {
|
(): Promise<github.ReposGetResponseData> => {
|
||||||
return <Promise<ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
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 * as github from '../src/github';
|
||||||
import {Meta, Version} from '../src/meta';
|
import {Meta, Version} from '../src/meta';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
|
||||||
|
|
||||||
jest.spyOn(github, 'repo').mockImplementation(
|
jest.spyOn(github, 'repo').mockImplementation(
|
||||||
(): Promise<ReposGetResponseData> => {
|
(): Promise<github.ReposGetResponseData> => {
|
||||||
return <Promise<ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
return <Promise<github.ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,18 +1,18 @@
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
import {Context} from '@actions/github/lib/context';
|
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 {
|
export function context(): Context {
|
||||||
return github.context;
|
return github.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function repo(token: string): Promise<ReposGetResponseData> {
|
export async function repo(token: string): Promise<ReposGetResponseData> {
|
||||||
const octokit = github.getOctokit(token);
|
return github
|
||||||
const repo = await octokit.repos.get({
|
.getOctokit(token)
|
||||||
|
.rest.repos.get({
|
||||||
...github.context.repo
|
...github.context.repo
|
||||||
});
|
})
|
||||||
if (!repo?.data) {
|
.then(response => response.data as ReposGetResponseData);
|
||||||
throw new Error('Cannot get GitHub repository');
|
|
||||||
}
|
|
||||||
return repo.data;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import * as github from './github';
|
||||||
import {Meta, Version} from './meta';
|
import {Meta, Version} from './meta';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
@ -14,7 +13,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const context: Context = github.context();
|
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.startGroup(`Context info`);
|
||||||
core.info(`eventName: ${context.eventName}`);
|
core.info(`eventName: ${context.eventName}`);
|
||||||
core.info(`sha: ${context.sha}`);
|
core.info(`sha: ${context.sha}`);
|
||||||
|
|
|
@ -4,11 +4,11 @@ import * as path from 'path';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import {Inputs, tmpDir} from './context';
|
import {Inputs, tmpDir} from './context';
|
||||||
|
import {ReposGetResponseData} from './github';
|
||||||
import * as tcl from './tag';
|
import * as tcl from './tag';
|
||||||
import * as fcl from './flavor';
|
import * as fcl from './flavor';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
|
||||||
|
|
||||||
export interface Version {
|
export interface Version {
|
||||||
main: string | undefined;
|
main: string | undefined;
|
||||||
|
|
Loading…
Reference in New Issue