Always use api.github.com

The octokit client would default to the URL of enterprise instances and then not be able to find the ruff repo.
This commit is contained in:
Kevin Stillhammer
2025-01-28 21:09:08 +01:00
parent 2993ff4a65
commit 276e678697
4 changed files with 9 additions and 3 deletions
Generated Vendored
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+8 -3
View File
@@ -2,7 +2,12 @@ import * as core from "@actions/core";
import * as tc from "@actions/tool-cache"; import * as tc from "@actions/tool-cache";
import * as path from "node:path"; import * as path from "node:path";
import { promises as fs } from "node:fs"; import { promises as fs } from "node:fs";
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants"; import {
GITHUB_COM_API,
OWNER,
REPO,
TOOL_CACHE_NAME,
} from "../utils/constants";
import type { Architecture, Platform } from "../utils/platforms"; import type { Architecture, Platform } from "../utils/platforms";
import { validateChecksum } from "./checksum/checksum"; import { validateChecksum } from "./checksum/checksum";
import * as github from "@actions/github"; import * as github from "@actions/github";
@@ -84,7 +89,7 @@ export async function resolveVersion(
} }
async function getAvailableVersions(githubToken: string): Promise<string[]> { async function getAvailableVersions(githubToken: string): Promise<string[]> {
const octokit = github.getOctokit(githubToken); const octokit = github.getOctokit(githubToken, { baseUrl: GITHUB_COM_API });
const response = await octokit.paginate(octokit.rest.repos.listReleases, { const response = await octokit.paginate(octokit.rest.repos.listReleases, {
owner: OWNER, owner: OWNER,
@@ -94,7 +99,7 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
} }
async function getLatestVersion(githubToken: string) { async function getLatestVersion(githubToken: string) {
const octokit = github.getOctokit(githubToken); const octokit = github.getOctokit(githubToken, { baseUrl: GITHUB_COM_API });
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({ const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
owner: OWNER, owner: OWNER,
+1
View File
@@ -1,3 +1,4 @@
export const REPO = "ruff"; export const REPO = "ruff";
export const OWNER = "astral-sh"; export const OWNER = "astral-sh";
export const TOOL_CACHE_NAME = "ruff"; export const TOOL_CACHE_NAME = "ruff";
export const GITHUB_COM_API = "https://api.github.com";