git: drop types/git and inline GitHub context type

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2026-01-28 12:08:36 +01:00
parent 3f7be6d97d
commit 9348f81855
3 changed files with 5 additions and 26 deletions

View File

@@ -15,18 +15,18 @@
*/
import * as core from '@actions/core';
import * as github from '@actions/github';
import {Octokit} from '@octokit/core';
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods';
import {Exec} from './exec.js';
import {GitHub} from './github.js';
import {Context} from '@actions/github/lib/context';
import {Context as GitContext} from './types/git.js';
export type GitContext = typeof github.context;
export class Git {
public static async context(): Promise<GitContext> {
const ctx = new Context();
const ctx = {...github.context} as GitContext;
ctx.ref = await Git.ref();
ctx.sha = await Git.fullCommit();
return ctx;

View File

@@ -29,8 +29,6 @@ import {InvalidResponseError, NetworkError} from '@actions/artifact';
import * as core from '@actions/core';
import {SummaryTableCell} from '@actions/core/lib/summary';
import * as github from '@actions/github';
import {GitHub as Octokit} from '@actions/github/lib/utils';
import {Context} from '@actions/github/lib/context';
import * as httpm from '@actions/http-client';
import {TransferProgressEvent} from '@azure/core-rest-pipeline';
import {BlobClient, BlobHTTPHeaders} from '@azure/storage-blob';
@@ -46,7 +44,7 @@ export interface GitHubOpts {
export class GitHub {
private readonly githubToken?: string;
public readonly octokit: InstanceType<typeof Octokit>;
public readonly octokit: ReturnType<typeof github.getOctokit>;
constructor(opts?: GitHubOpts) {
this.githubToken = opts?.token || process.env.GITHUB_TOKEN;
@@ -87,7 +85,7 @@ export class GitHub {
return <Record<string, GitHubRelease>>JSON.parse(dt);
}
static get context(): Context {
static get context(): typeof github.context {
return github.context;
}

View File

@@ -1,19 +0,0 @@
/**
* Copyright 2023 actions-toolkit authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Context as GitHubContext} from '@actions/github/lib/context';
export type Context = GitHubContext;