diff --git a/action.yml b/action.yml index 4a4df38..554c021 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,6 @@ inputs: default: 'latest' auth_token: description: 'GitHub token for authentication.' - default: '' runs: using: 'node20' diff --git a/dist/index.js b/dist/index.js index 1f60a76..8e379f5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7805,7 +7805,7 @@ var import_endpoint = __nccwpck_require__(9440); var import_universal_user_agent = __nccwpck_require__(5030); // pkg/dist-src/version.js -var VERSION = "8.3.1"; +var VERSION = "8.4.0"; // pkg/dist-src/is-plain-object.js function isPlainObject(value) { @@ -7830,7 +7830,7 @@ function getBufferResponse(response) { // pkg/dist-src/fetch-wrapper.js function fetchWrapper(requestOptions) { - var _a, _b, _c; + var _a, _b, _c, _d; const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; const parseSuccessResponseBody = ((_a = requestOptions.request) == null ? void 0 : _a.parseSuccessResponseBody) !== false; if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { @@ -7851,8 +7851,9 @@ function fetchWrapper(requestOptions) { return fetch(requestOptions.url, { method: requestOptions.method, body: requestOptions.body, + redirect: (_c = requestOptions.request) == null ? void 0 : _c.redirect, headers: requestOptions.headers, - signal: (_c = requestOptions.request) == null ? void 0 : _c.signal, + signal: (_d = requestOptions.request) == null ? void 0 : _d.signal, // duplex must be set if request.body is ReadableStream or Async Iterables. // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. ...requestOptions.body && { duplex: "half" } @@ -35637,7 +35638,7 @@ function wrappy (fn, cb) { /***/ }), /***/ 6932: -/***/ (function(__unused_webpack_module, exports) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -35651,7 +35652,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getReleaseUrlByVersion = void 0; +exports.getReleaseUrlByVersion = exports.getOctokit = void 0; +const rest_1 = __nccwpck_require__(5375); +const utils_1 = __nccwpck_require__(3030); +function getOctokit(auth_token) { + let options = {}; + if (auth_token) { + options = (0, utils_1.getOctokitOptions)(auth_token, options); + } + return new rest_1.Octokit(options); +} +exports.getOctokit = getOctokit; function getReleaseDownloadUrl(octokit, owner, repo, release_id) { return __awaiter(this, void 0, void 0, function* () { let assets = yield octokit.rest.repos.listReleaseAssets({ @@ -35824,8 +35835,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); -const utils_1 = __nccwpck_require__(3030); -const rest_1 = __nccwpck_require__(5375); const github_helper = __importStar(__nccwpck_require__(6932)); const installer = __importStar(__nccwpck_require__(2574)); function run() { @@ -35840,7 +35849,7 @@ function run() { // First obtain a valid download url.. if (!download_url) { core.debug("Using owner, repo and version inputs to locate a release..."); - const octokit = new rest_1.Octokit((0, utils_1.getOctokitOptions)(auth_token)); + const octokit = github_helper.getOctokit(auth_token); download_url = yield github_helper.getReleaseUrlByVersion(octokit, owner, repo, version); } else { diff --git a/src/github_helper.test.ts b/src/github_helper.test.ts index f74c343..b2abb3d 100644 --- a/src/github_helper.test.ts +++ b/src/github_helper.test.ts @@ -1,7 +1,12 @@ import { Octokit } from "@octokit/rest"; import * as github_helper from "./github_helper"; -const octokit = new Octokit(); +test("Oktokit getter", () => { + const octokit = github_helper.getOctokit(); + expect(octokit).not.toBe(null); +}); + +const octokit = github_helper.getOctokit(); test("Verify Ghidra 10.4 download URL", async () => { const url = await github_helper.getReleaseUrlByVersion( diff --git a/src/github_helper.ts b/src/github_helper.ts index a71c94a..6be62de 100644 --- a/src/github_helper.ts +++ b/src/github_helper.ts @@ -1,4 +1,13 @@ import { Octokit } from "@octokit/rest"; +import { getOctokitOptions } from "@actions/github/lib/utils"; + +export function getOctokit(auth_token?: string) { + let options = {}; + if (auth_token) { + options = getOctokitOptions(auth_token, options); + } + return new Octokit(options); +} async function getReleaseDownloadUrl( octokit: Octokit, diff --git a/src/setup-ghidra.ts b/src/setup-ghidra.ts index 7c51fb0..aaffc93 100644 --- a/src/setup-ghidra.ts +++ b/src/setup-ghidra.ts @@ -1,6 +1,4 @@ import * as core from "@actions/core"; -import { getOctokitOptions } from "@actions/github/lib/utils"; -import { Octokit } from "@octokit/rest"; import * as github_helper from "./github_helper"; import * as installer from "./installer"; @@ -16,7 +14,7 @@ async function run() { // First obtain a valid download url.. if (!download_url) { core.debug("Using owner, repo and version inputs to locate a release..."); - const octokit = new Octokit(getOctokitOptions(auth_token)); + const octokit = github_helper.getOctokit(auth_token); download_url = await github_helper.getReleaseUrlByVersion( octokit, owner,