github: move types

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-01 13:06:20 +01:00
parent dea2294b93
commit fe8b21ecf5
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 14 additions and 9 deletions

View File

@ -18,13 +18,14 @@ import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import {GitHub, GitHubRepo} from '../src/github'; import {GitHub} from '../src/github';
import {GitHubRepo} from '../src/types/github';
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
import * as repoFixture from './fixtures/repo.json'; import repoFixture from './fixtures/repo.json';
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => { jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
return <Promise<GitHubRepo>>(repoFixture as unknown); return <Promise<GitHubRepo>>(repoFixture as unknown);
}); });

View File

@ -16,15 +16,10 @@
import {GitHub as Octokit} from '@actions/github/lib/utils'; import {GitHub as Octokit} from '@actions/github/lib/utils';
import * as github from '@actions/github'; import * as github from '@actions/github';
import {components as OctoOpenApiTypes} from '@octokit/openapi-types';
import jwt_decode, {JwtPayload} from 'jwt-decode';
import {Context} from '@actions/github/lib/context'; import {Context} from '@actions/github/lib/context';
import jwt_decode from 'jwt-decode';
export type GitHubRepo = OctoOpenApiTypes['schemas']['repository']; import {GitHubActionsRuntimeToken, GitHubRepo} from './types/github';
export interface GitHubActionsRuntimeToken extends JwtPayload {
ac?: string;
}
export interface GitHubOpts { export interface GitHubOpts {
token?: string; token?: string;

View File

@ -14,9 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
import {components as OctoOpenApiTypes} from '@octokit/openapi-types';
import {JwtPayload} from 'jwt-decode';
export interface GitHubRelease { export interface GitHubRelease {
id: number; id: number;
tag_name: string; tag_name: string;
html_url: string; html_url: string;
assets: Array<string>; assets: Array<string>;
} }
export type GitHubRepo = OctoOpenApiTypes['schemas']['repository'];
export interface GitHubActionsRuntimeToken extends JwtPayload {
ac?: string;
}