mirror of
https://github.com/actions/github-script.git
synced 2026-01-03 22:13:06 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
100527700e | ||
|
|
085a7754e8 | ||
|
|
6871f0ffce | ||
|
|
7ed718295b | ||
|
|
7dff1a8764 | ||
|
|
8445ca871a |
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.9.1
|
version: 1.10.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions core lib
|
summary: Actions core lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
|||||||
2
.licenses/npm/@actions/github.dep.yml
generated
2
.licenses/npm/@actions/github.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/github"
|
name: "@actions/github"
|
||||||
version: 5.1.0
|
version: 5.1.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions github lib
|
summary: Actions github lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/github
|
homepage: https://github.com/actions/toolkit/tree/main/packages/github
|
||||||
|
|||||||
@@ -4,38 +4,66 @@ import {getRetryOptions} from '../src/retry-options'
|
|||||||
|
|
||||||
describe('getRequestOptions', () => {
|
describe('getRequestOptions', () => {
|
||||||
test('retries disabled if retries == 0', async () => {
|
test('retries disabled if retries == 0', async () => {
|
||||||
const [retryOptions, requestOptions] = getRetryOptions(0, [400, 500, 502])
|
const [retryOptions, requestOptions] = getRetryOptions(
|
||||||
|
0,
|
||||||
|
[400, 500, 502],
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
expect(retryOptions.enabled).toBe(false)
|
expect(retryOptions.enabled).toBe(false)
|
||||||
expect(retryOptions.doNotRetry).toBeFalsy()
|
expect(retryOptions.doNotRetry).toBeFalsy()
|
||||||
|
|
||||||
expect(requestOptions.retries).toBeFalsy()
|
expect(requestOptions?.retries).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('properties set if retries > 0', async () => {
|
test('properties set if retries > 0', async () => {
|
||||||
const [retryOptions, requestOptions] = getRetryOptions(1, [400, 500, 502])
|
const [retryOptions, requestOptions] = getRetryOptions(
|
||||||
|
1,
|
||||||
|
[400, 500, 502],
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
expect(retryOptions.enabled).toBe(true)
|
expect(retryOptions.enabled).toBe(true)
|
||||||
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])
|
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])
|
||||||
|
|
||||||
expect(requestOptions.retries).toEqual(1)
|
expect(requestOptions?.retries).toEqual(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('properties set if retries > 0', async () => {
|
test('properties set if retries > 0', async () => {
|
||||||
const [retryOptions, requestOptions] = getRetryOptions(1, [400, 500, 502])
|
const [retryOptions, requestOptions] = getRetryOptions(
|
||||||
|
1,
|
||||||
|
[400, 500, 502],
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
expect(retryOptions.enabled).toBe(true)
|
expect(retryOptions.enabled).toBe(true)
|
||||||
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])
|
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])
|
||||||
|
|
||||||
expect(requestOptions.retries).toEqual(1)
|
expect(requestOptions?.retries).toEqual(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('retryOptions.doNotRetry not set if exemptStatusCodes isEmpty', async () => {
|
test('retryOptions.doNotRetry not set if exemptStatusCodes isEmpty', async () => {
|
||||||
const [retryOptions, requestOptions] = getRetryOptions(1, [])
|
const [retryOptions, requestOptions] = getRetryOptions(1, [], [])
|
||||||
|
|
||||||
expect(retryOptions.enabled).toBe(true)
|
expect(retryOptions.enabled).toBe(true)
|
||||||
expect(retryOptions.doNotRetry).toBeUndefined()
|
expect(retryOptions.doNotRetry).toBeUndefined()
|
||||||
|
|
||||||
expect(requestOptions.retries).toEqual(1)
|
expect(requestOptions?.retries).toEqual(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('requestOptions does not override defaults from @actions/github', async () => {
|
||||||
|
const [retryOptions, requestOptions] = getRetryOptions(1, [], {
|
||||||
|
request: {
|
||||||
|
agent: 'default-user-agent'
|
||||||
|
},
|
||||||
|
foo: 'bar'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(retryOptions.enabled).toBe(true)
|
||||||
|
expect(retryOptions.doNotRetry).toBeUndefined()
|
||||||
|
|
||||||
|
expect(requestOptions?.retries).toEqual(1)
|
||||||
|
expect(requestOptions?.agent).toEqual('default-user-agent')
|
||||||
|
expect(requestOptions?.foo).toBeUndefined() // this should not be in the `options.request` object, but at the same level as `request`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
77
dist/index.js
vendored
77
dist/index.js
vendored
@@ -246,7 +246,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
|
exports.getOctokitOptions = exports.GitHub = exports.defaults = exports.context = void 0;
|
||||||
const Context = __importStar(__webpack_require__(53));
|
const Context = __importStar(__webpack_require__(53));
|
||||||
const Utils = __importStar(__webpack_require__(914));
|
const Utils = __importStar(__webpack_require__(914));
|
||||||
// octokit + plugins
|
// octokit + plugins
|
||||||
@@ -255,13 +255,13 @@ const plugin_rest_endpoint_methods_1 = __webpack_require__(45);
|
|||||||
const plugin_paginate_rest_1 = __webpack_require__(193);
|
const plugin_paginate_rest_1 = __webpack_require__(193);
|
||||||
exports.context = new Context.Context();
|
exports.context = new Context.Context();
|
||||||
const baseUrl = Utils.getApiBaseUrl();
|
const baseUrl = Utils.getApiBaseUrl();
|
||||||
const defaults = {
|
exports.defaults = {
|
||||||
baseUrl,
|
baseUrl,
|
||||||
request: {
|
request: {
|
||||||
agent: Utils.getProxyAgent(baseUrl)
|
agent: Utils.getProxyAgent(baseUrl)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
|
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports.defaults);
|
||||||
/**
|
/**
|
||||||
* Convience function to correctly format Octokit Options to pass into the constructor.
|
* Convience function to correctly format Octokit Options to pass into the constructor.
|
||||||
*
|
*
|
||||||
@@ -5217,7 +5217,6 @@ const file_command_1 = __webpack_require__(717);
|
|||||||
const utils_1 = __webpack_require__(278);
|
const utils_1 = __webpack_require__(278);
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const uuid_1 = __webpack_require__(840);
|
|
||||||
const oidc_utils_1 = __webpack_require__(41);
|
const oidc_utils_1 = __webpack_require__(41);
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
@@ -5247,20 +5246,9 @@ function exportVariable(name, val) {
|
|||||||
process.env[name] = convertedVal;
|
process.env[name] = convertedVal;
|
||||||
const filePath = process.env['GITHUB_ENV'] || '';
|
const filePath = process.env['GITHUB_ENV'] || '';
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
||||||
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
|
|
||||||
if (name.includes(delimiter)) {
|
|
||||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
|
||||||
}
|
|
||||||
if (convertedVal.includes(delimiter)) {
|
|
||||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
|
||||||
}
|
|
||||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
|
||||||
file_command_1.issueCommand('ENV', commandValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
||||||
}
|
}
|
||||||
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@@ -5278,7 +5266,7 @@ exports.setSecret = setSecret;
|
|||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
const filePath = process.env['GITHUB_PATH'] || '';
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
file_command_1.issueCommand('PATH', inputPath);
|
file_command_1.issueFileCommand('PATH', inputPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
@@ -5318,7 +5306,10 @@ function getMultilineInput(name, options) {
|
|||||||
const inputs = getInput(name, options)
|
const inputs = getInput(name, options)
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(x => x !== '');
|
.filter(x => x !== '');
|
||||||
return inputs;
|
if (options && options.trimWhitespace === false) {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
return inputs.map(input => input.trim());
|
||||||
}
|
}
|
||||||
exports.getMultilineInput = getMultilineInput;
|
exports.getMultilineInput = getMultilineInput;
|
||||||
/**
|
/**
|
||||||
@@ -5351,8 +5342,12 @@ exports.getBooleanInput = getBooleanInput;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
|
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
||||||
|
}
|
||||||
process.stdout.write(os.EOL);
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
/**
|
/**
|
||||||
@@ -5481,7 +5476,11 @@ exports.group = group;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function saveState(name, value) {
|
function saveState(name, value) {
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
const filePath = process.env['GITHUB_STATE'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
||||||
|
}
|
||||||
|
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
||||||
}
|
}
|
||||||
exports.saveState = saveState;
|
exports.saveState = saveState;
|
||||||
/**
|
/**
|
||||||
@@ -12117,13 +12116,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.issueCommand = void 0;
|
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
||||||
// We use any as a valid input type
|
// We use any as a valid input type
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
const uuid_1 = __webpack_require__(840);
|
||||||
const utils_1 = __webpack_require__(278);
|
const utils_1 = __webpack_require__(278);
|
||||||
function issueCommand(command, message) {
|
function issueFileCommand(command, message) {
|
||||||
const filePath = process.env[`GITHUB_${command}`];
|
const filePath = process.env[`GITHUB_${command}`];
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||||
@@ -12135,7 +12135,22 @@ function issueCommand(command, message) {
|
|||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.issueCommand = issueCommand;
|
exports.issueFileCommand = issueFileCommand;
|
||||||
|
function prepareKeyValueMessage(key, value) {
|
||||||
|
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||||
|
const convertedValue = utils_1.toCommandValue(value);
|
||||||
|
// These should realistically never happen, but just in case someone finds a
|
||||||
|
// way to exploit uuid generation let's not allow keys or values that contain
|
||||||
|
// the delimiter.
|
||||||
|
if (key.includes(delimiter)) {
|
||||||
|
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||||||
|
}
|
||||||
|
if (convertedValue.includes(delimiter)) {
|
||||||
|
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||||||
|
}
|
||||||
|
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
||||||
|
}
|
||||||
|
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
||||||
//# sourceMappingURL=file-command.js.map
|
//# sourceMappingURL=file-command.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -13322,6 +13337,9 @@ var exec = __webpack_require__(514);
|
|||||||
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
|
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
|
||||||
var lib_github = __webpack_require__(438);
|
var lib_github = __webpack_require__(438);
|
||||||
|
|
||||||
|
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/utils.js
|
||||||
|
var utils = __webpack_require__(30);
|
||||||
|
|
||||||
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
|
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
|
||||||
var glob = __webpack_require__(90);
|
var glob = __webpack_require__(90);
|
||||||
|
|
||||||
@@ -13340,10 +13358,10 @@ function callAsyncFunction(args, source) {
|
|||||||
|
|
||||||
// CONCATENATED MODULE: ./src/retry-options.ts
|
// CONCATENATED MODULE: ./src/retry-options.ts
|
||||||
|
|
||||||
function getRetryOptions(retries, exemptStatusCodes) {
|
function getRetryOptions(retries, exemptStatusCodes, defaultOptions) {
|
||||||
var _a;
|
var _a;
|
||||||
if (retries <= 0) {
|
if (retries <= 0) {
|
||||||
return [{ enabled: false }, {}];
|
return [{ enabled: false }, defaultOptions.request];
|
||||||
}
|
}
|
||||||
const retryOptions = {
|
const retryOptions = {
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -13351,7 +13369,11 @@ function getRetryOptions(retries, exemptStatusCodes) {
|
|||||||
if (exemptStatusCodes.length > 0) {
|
if (exemptStatusCodes.length > 0) {
|
||||||
retryOptions.doNotRetry = exemptStatusCodes;
|
retryOptions.doNotRetry = exemptStatusCodes;
|
||||||
}
|
}
|
||||||
|
// The GitHub type has some defaults for `options.request`
|
||||||
|
// see: https://github.com/actions/toolkit/blob/4fbc5c941a57249b19562015edbd72add14be93d/packages/github/src/utils.ts#L15
|
||||||
|
// We pass these in here so they are not overidden.
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
|
...defaultOptions.request,
|
||||||
retries
|
retries
|
||||||
};
|
};
|
||||||
Object(core.debug)(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions === null || retryOptions === void 0 ? void 0 : retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : 'octokit default: [400, 401, 403, 404, 422]'})`);
|
Object(core.debug)(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions === null || retryOptions === void 0 ? void 0 : retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : 'octokit default: [400, 401, 403, 404, 422]'})`);
|
||||||
@@ -13401,6 +13423,7 @@ const wrapRequire = new Proxy(require, {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process.on('unhandledRejection', handleError);
|
process.on('unhandledRejection', handleError);
|
||||||
main().catch(handleError);
|
main().catch(handleError);
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -13410,7 +13433,7 @@ async function main() {
|
|||||||
const previews = Object(core.getInput)('previews');
|
const previews = Object(core.getInput)('previews');
|
||||||
const retries = parseInt(Object(core.getInput)('retries'));
|
const retries = parseInt(Object(core.getInput)('retries'));
|
||||||
const exemptStatusCodes = parseNumberArray(Object(core.getInput)('retry-exempt-status-codes'));
|
const exemptStatusCodes = parseNumberArray(Object(core.getInput)('retry-exempt-status-codes'));
|
||||||
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes);
|
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults);
|
||||||
const opts = {};
|
const opts = {};
|
||||||
if (debug === 'true')
|
if (debug === 'true')
|
||||||
opts.log = console;
|
opts.log = console;
|
||||||
|
|||||||
30
package-lock.json
generated
30
package-lock.json
generated
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "github-script",
|
"name": "github-script",
|
||||||
"version": "6.3.0",
|
"version": "6.3.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "github-script",
|
"name": "github-script",
|
||||||
"version": "6.3.0",
|
"version": "6.3.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.9.1",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.0.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
@@ -35,9 +35,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.9.1",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
@@ -52,9 +52,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/github": {
|
"node_modules/@actions/github": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||||
"integrity": "sha512-tuI80F7JQIhg77ZTTgUAPpVD7ZnP9oHSPN8xw7LOwtA4vEMbAjWJNbmLBfV7xua7r016GyjzWLuec5cs8f/a8A==",
|
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@octokit/core": "^3.6.0",
|
"@octokit/core": "^3.6.0",
|
||||||
@@ -6225,9 +6225,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.9.1",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
@@ -6242,9 +6242,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/github": {
|
"@actions/github": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||||
"integrity": "sha512-tuI80F7JQIhg77ZTTgUAPpVD7ZnP9oHSPN8xw7LOwtA4vEMbAjWJNbmLBfV7xua7r016GyjzWLuec5cs8f/a8A==",
|
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@octokit/core": "^3.6.0",
|
"@octokit/core": "^3.6.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "github-script",
|
"name": "github-script",
|
||||||
"description": "A GitHub action for executing a simple script",
|
"description": "A GitHub action for executing a simple script",
|
||||||
"version": "6.3.0",
|
"version": "6.3.2",
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.9.1",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.0.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
@@ -55,4 +55,4 @@
|
|||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
17
src/main.ts
17
src/main.ts
@@ -1,16 +1,13 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import {context, getOctokit} from '@actions/github'
|
import {context, getOctokit} from '@actions/github'
|
||||||
|
import {defaults as defaultGitHubOptions} from '@actions/github/lib/utils'
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import {retry} from '@octokit/plugin-retry'
|
import {retry} from '@octokit/plugin-retry'
|
||||||
|
import {RequestRequestOptions} from '@octokit/types'
|
||||||
import {callAsyncFunction} from './async-function'
|
import {callAsyncFunction} from './async-function'
|
||||||
import {
|
import {getRetryOptions, parseNumberArray, RetryOptions} from './retry-options'
|
||||||
getRetryOptions,
|
|
||||||
parseNumberArray,
|
|
||||||
RequestOptions,
|
|
||||||
RetryOptions
|
|
||||||
} from './retry-options'
|
|
||||||
import {wrapRequire} from './wrap-require'
|
import {wrapRequire} from './wrap-require'
|
||||||
|
|
||||||
process.on('unhandledRejection', handleError)
|
process.on('unhandledRejection', handleError)
|
||||||
@@ -21,7 +18,7 @@ type Options = {
|
|||||||
userAgent?: string
|
userAgent?: string
|
||||||
previews?: string[]
|
previews?: string[]
|
||||||
retry?: RetryOptions
|
retry?: RetryOptions
|
||||||
request?: RequestOptions
|
request?: RequestRequestOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
@@ -33,7 +30,11 @@ async function main(): Promise<void> {
|
|||||||
const exemptStatusCodes = parseNumberArray(
|
const exemptStatusCodes = parseNumberArray(
|
||||||
core.getInput('retry-exempt-status-codes')
|
core.getInput('retry-exempt-status-codes')
|
||||||
)
|
)
|
||||||
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes)
|
const [retryOpts, requestOpts] = getRetryOptions(
|
||||||
|
retries,
|
||||||
|
exemptStatusCodes,
|
||||||
|
defaultGitHubOptions
|
||||||
|
)
|
||||||
|
|
||||||
const opts: Options = {}
|
const opts: Options = {}
|
||||||
if (debug === 'true') opts.log = console
|
if (debug === 'true') opts.log = console
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||||
|
import {RequestRequestOptions} from '@octokit/types'
|
||||||
|
|
||||||
export type RetryOptions = {
|
export type RetryOptions = {
|
||||||
doNotRetry?: number[]
|
doNotRetry?: number[]
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RequestOptions = {
|
|
||||||
retries?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getRetryOptions(
|
export function getRetryOptions(
|
||||||
retries: number,
|
retries: number,
|
||||||
exemptStatusCodes: number[]
|
exemptStatusCodes: number[],
|
||||||
): [RetryOptions, RequestOptions] {
|
defaultOptions: OctokitOptions
|
||||||
|
): [RetryOptions, RequestRequestOptions | undefined] {
|
||||||
if (retries <= 0) {
|
if (retries <= 0) {
|
||||||
return [{enabled: false}, {}]
|
return [{enabled: false}, defaultOptions.request]
|
||||||
}
|
}
|
||||||
|
|
||||||
const retryOptions: RetryOptions = {
|
const retryOptions: RetryOptions = {
|
||||||
@@ -25,7 +24,11 @@ export function getRetryOptions(
|
|||||||
retryOptions.doNotRetry = exemptStatusCodes
|
retryOptions.doNotRetry = exemptStatusCodes
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestOptions: RequestOptions = {
|
// The GitHub type has some defaults for `options.request`
|
||||||
|
// see: https://github.com/actions/toolkit/blob/4fbc5c941a57249b19562015edbd72add14be93d/packages/github/src/utils.ts#L15
|
||||||
|
// We pass these in here so they are not overidden.
|
||||||
|
const requestOptions: RequestRequestOptions = {
|
||||||
|
...defaultOptions.request,
|
||||||
retries
|
retries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user