From 3c2ce6b9bda6a4581df8904d15121751673a3f83 Mon Sep 17 00:00:00 2001 From: softprops Date: Sat, 7 Aug 2021 18:50:31 -0400 Subject: [PATCH] try alt constructor --- dist/index.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/main.ts | 42 ++++++++++++++++++++++-------------------- 2 files changed, 70 insertions(+), 22 deletions(-) diff --git a/dist/index.js b/dist/index.js index 878d18f..9c4eb04 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2100,6 +2100,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = __webpack_require__(322); const github_1 = __webpack_require__(146); +const github_2 = __webpack_require__(469); const core_1 = __webpack_require__(470); const utils_1 = __webpack_require__(521); const process_1 = __webpack_require__(765); @@ -2120,7 +2121,8 @@ function run() { } } const oktokit = utils_1.GitHub.plugin(__webpack_require__(617), __webpack_require__(755)); - const gh = new oktokit(utils_1.getOctokitOptions(config.github_token, { + const gh = github_2.getOctokit(config.github_token, { + //new oktokit( throttle: { onRateLimit: (retryAfter, options) => { console.warn(`Request quota exhausted for request ${options.method} ${options.url}`); @@ -2135,7 +2137,8 @@ function run() { console.warn(`Abuse detected for request ${options.method} ${options.url}`); } } - })); + }); + //); let rel = yield github_1.release(config, new github_1.GitHubReleaser(gh)); if (config.input_files) { const files = util_1.paths(config.input_files); @@ -7884,6 +7887,49 @@ exports.RequestError = RequestError; //# sourceMappingURL=index.js.map +/***/ }), + +/***/ 469: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getOctokit = exports.context = void 0; +const Context = __importStar(__webpack_require__(262)); +const utils_1 = __webpack_require__(521); +exports.context = new Context.Context(); +/** + * Returns a hydrated octokit ready to use for GitHub Actions + * + * @param token the repo PAT or GITHUB_TOKEN + * @param options other options to set + */ +function getOctokit(token, options) { + return new utils_1.GitHub(utils_1.getOctokitOptions(token, options)); +} +exports.getOctokit = getOctokit; +//# sourceMappingURL=github.js.map + /***/ }), /***/ 470: diff --git a/src/main.ts b/src/main.ts index b3704d0..59129ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import { paths, parseConfig, isTag, unmatchedPatterns } from "./util"; import { release, upload, GitHubReleaser } from "./github"; +import { getOctokit } from "@actions/github"; import { setFailed, setOutput } from "@actions/core"; import { GitHub, getOctokitOptions } from "@actions/github/lib/utils"; @@ -24,33 +25,34 @@ async function run() { throw new Error(`⚠️ There were unmatched files`); } } + const oktokit = GitHub.plugin( require("@octokit/plugin-throttling"), require("@octokit/plugin-retry") ); - const gh = new oktokit( - getOctokitOptions(config.github_token, { - throttle: { - onRateLimit: (retryAfter, options) => { - console.warn( - `Request quota exhausted for request ${options.method} ${options.url}` - ); - if (options.request.retryCount === 0) { - // only retries once - console.log(`Retrying after ${retryAfter} seconds!`); - return true; - } - }, - onAbuseLimit: (retryAfter, options) => { - // does not retry, only logs a warning - console.warn( - `Abuse detected for request ${options.method} ${options.url}` - ); + const gh = getOctokit(config.github_token, { + //new oktokit( + throttle: { + onRateLimit: (retryAfter, options) => { + console.warn( + `Request quota exhausted for request ${options.method} ${options.url}` + ); + if (options.request.retryCount === 0) { + // only retries once + console.log(`Retrying after ${retryAfter} seconds!`); + return true; } + }, + onAbuseLimit: (retryAfter, options) => { + // does not retry, only logs a warning + console.warn( + `Abuse detected for request ${options.method} ${options.url}` + ); } - }) - ); + } + }); + //); let rel = await release(config, new GitHubReleaser(gh)); if (config.input_files) { const files = paths(config.input_files);