mirror of
https://github.com/actions/github-script.git
synced 2026-10-15 20:06:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7906e4ad0 | ||
|
|
ea954ff83a | ||
|
|
57c10d434e | ||
|
|
eae7dc1b88 | ||
|
|
f1ab5779d6 | ||
|
|
8d9f8fc050 | ||
|
|
a4f398e58b | ||
|
|
806be26275 | ||
|
|
8d76c9a913 | ||
|
|
78f623b2da |
No files matched your search
@@ -6,8 +6,11 @@ extends:
|
|||||||
- plugin:@typescript-eslint/eslint-recommended
|
- plugin:@typescript-eslint/eslint-recommended
|
||||||
- plugin:@typescript-eslint/recommended
|
- plugin:@typescript-eslint/recommended
|
||||||
- prettier/@typescript-eslint
|
- prettier/@typescript-eslint
|
||||||
|
parserOptions:
|
||||||
|
project: ['tsconfig.eslint.json']
|
||||||
rules:
|
rules:
|
||||||
# '@typescript-eslint/explicit-function-return-type': 0
|
# '@typescript-eslint/explicit-function-return-type': 0
|
||||||
'@typescript-eslint/no-use-before-define':
|
'@typescript-eslint/no-use-before-define':
|
||||||
- 2
|
- 2
|
||||||
- functions: false
|
- functions: false
|
||||||
|
'@typescript-eslint/no-unnecessary-condition': error
|
||||||
@@ -8,6 +8,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-return:
|
test-return:
|
||||||
|
name: 'Integration test: return'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -18,26 +19,34 @@ jobs:
|
|||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
input-value: output
|
||||||
- run: |
|
- run: |
|
||||||
if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then
|
echo "- Validating output is produced"
|
||||||
|
expected="output"
|
||||||
|
if [[ "${{steps.output-set.outputs.result}}" != "$expected" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.output-set.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
test-relative-require:
|
test-relative-require:
|
||||||
|
name: 'Integration test: relative-path require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- id: output-set
|
- id: relative-require
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
script: return require('./package.json').name
|
script: return require('./package.json').name
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
|
||||||
- run: |
|
- run: |
|
||||||
if [[ "${{steps.output-set.outputs.result}}" != "github-script" ]]; then
|
echo "- Validating relative require output"
|
||||||
|
if [[ "${{steps.relative-require.outputs.result}}" != "github-script" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
test-npm-require:
|
test-npm-require:
|
||||||
|
name: 'Integration test: npm package require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -47,13 +56,215 @@ jobs:
|
|||||||
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
||||||
restore-keys: ${{runner.os}}-npm-
|
restore-keys: ${{runner.os}}-npm-
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- id: output-set
|
- id: npm-require
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
script: return require('@actions/core/package.json').name
|
script: return require('@actions/core/package.json').name
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
|
||||||
- run: |
|
- run: |
|
||||||
if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then
|
echo "- Validating npm require output"
|
||||||
|
expected="@actions/core"
|
||||||
|
if [[ "${{steps.npm-require.outputs.result}}" != "$expected" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.npm-require.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
test-previews:
|
||||||
|
name: 'Integration test: previews option'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
||||||
|
restore-keys: ${{runner.os}}-npm-
|
||||||
|
- run: npm ci
|
||||||
|
- id: previews-default
|
||||||
|
name: Default previews not set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers.accept
|
||||||
|
result-encoding: string
|
||||||
|
- id: previews-set-single
|
||||||
|
name: Previews set to a single value
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
previews: foo
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers.accept
|
||||||
|
result-encoding: string
|
||||||
|
- id: previews-set-multiple
|
||||||
|
name: Previews set to comma-separated list
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
previews: foo,bar,baz
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers.accept
|
||||||
|
result-encoding: string
|
||||||
|
- run: |
|
||||||
|
echo "- Validating previews default"
|
||||||
|
expected="application/vnd.github.v3+json"
|
||||||
|
if [[ "${{steps.previews-default.outputs.result}}" != $expected ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-default.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "- Validating previews set to a single value"
|
||||||
|
expected="application/vnd.github.foo-preview+json"
|
||||||
|
if [[ "${{steps.previews-set-single.outputs.result}}" != $expected ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-single.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "- Validating previews set to multiple values"
|
||||||
|
expected="application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json,application/vnd.github.baz-preview+json"
|
||||||
|
if [[ "${{steps.previews-set-multiple.outputs.result}}" != $expected ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-multiple.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
test-user-agent:
|
||||||
|
name: 'Integration test: user-agent option'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
||||||
|
restore-keys: ${{runner.os}}-npm-
|
||||||
|
- run: npm ci
|
||||||
|
- id: user-agent-default
|
||||||
|
name: Default user-agent not set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers['user-agent']
|
||||||
|
result-encoding: string
|
||||||
|
- id: user-agent-set
|
||||||
|
name: User-agent set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
user-agent: foobar
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers['user-agent']
|
||||||
|
result-encoding: string
|
||||||
|
- id: user-agent-empty
|
||||||
|
name: User-agent set to an empty string
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
user-agent: ''
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({}).headers['user-agent']
|
||||||
|
result-encoding: string
|
||||||
|
- run: |
|
||||||
|
echo "- Validating user-agent default"
|
||||||
|
expected="actions/github-script octokit-core.js/"
|
||||||
|
if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "- Validating user-agent set to a value"
|
||||||
|
expected="foobar octokit-core.js/"
|
||||||
|
if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "- Validating user-agent set to an empty string"
|
||||||
|
expected="octokit-core.js/"
|
||||||
|
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
test-debug:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
environment: ['', 'debug-integration-test']
|
||||||
|
environment: ${{ matrix.environment }}
|
||||||
|
name: "Integration test: debug option (runner.debug mode ${{ matrix.environment && 'enabled' || 'disabled' }})"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
||||||
|
restore-keys: ${{runner.os}}-npm-
|
||||||
|
- run: npm ci
|
||||||
|
- id: debug-default
|
||||||
|
name: Default debug not set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const log = github.log
|
||||||
|
return {
|
||||||
|
runnerDebugMode: core.isDebug(),
|
||||||
|
debug: log.debug === console.debug,
|
||||||
|
info: log.info === console.info
|
||||||
|
}
|
||||||
|
- id: debug-true
|
||||||
|
name: Debug set to true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
debug: true
|
||||||
|
script: |
|
||||||
|
const log = github.log
|
||||||
|
return {
|
||||||
|
runnerDebugMode: core.isDebug(),
|
||||||
|
debug: log.debug === console.debug,
|
||||||
|
info: log.info === console.info
|
||||||
|
}
|
||||||
|
- id: debug-false
|
||||||
|
name: Debug set to false
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
debug: false
|
||||||
|
script: |
|
||||||
|
const log = github.log
|
||||||
|
return {
|
||||||
|
runnerDebugMode: core.isDebug(),
|
||||||
|
debug: log.debug === console.debug,
|
||||||
|
info: log.info === console.info
|
||||||
|
}
|
||||||
|
- id: evaluate-tests
|
||||||
|
name: Evaluate test outputs
|
||||||
|
env:
|
||||||
|
RDMODE: ${{ runner.debug == '1' }}
|
||||||
|
run: |
|
||||||
|
# tests table, pipe separated: label | output | expected
|
||||||
|
# leading and trailing spaces on any field are trimmed
|
||||||
|
tests=$(cat << 'TESTS'
|
||||||
|
Validating debug default |\
|
||||||
|
${{ steps.debug-default.outputs.result }} |\
|
||||||
|
{"runnerDebugMode":${{ env.RDMODE }},"debug":${{ env.RDMODE }},"info":${{ env.RDMODE }}}
|
||||||
|
Validating debug set to true |\
|
||||||
|
${{ steps.debug-true.outputs.result }} |\
|
||||||
|
{"runnerDebugMode":${{ env.RDMODE }},"debug":true,"info":true}
|
||||||
|
Validating debug set to false |\
|
||||||
|
${{ steps.debug-false.outputs.result }} |\
|
||||||
|
{"runnerDebugMode":${{ env.RDMODE }},"debug":false,"info":false}
|
||||||
|
TESTS
|
||||||
|
)
|
||||||
|
|
||||||
|
strim() { shopt -s extglob; lt="${1##+( )}"; echo "${lt%%+( )}"; }
|
||||||
|
while IFS='|' read label output expected; do
|
||||||
|
label="$(strim "$label")"; output="$(strim "$output")"; expected="$(strim "$expected")"
|
||||||
|
echo -n "- $label:"
|
||||||
|
if [[ "$output" != "$expected" ]]; then
|
||||||
|
echo $'\n::error::\u274C' "Expected '$expected', got '$output'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $' \u2705'
|
||||||
|
done <<< "$tests"
|
||||||
|
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
-2
@@ -13,8 +13,8 @@ inputs:
|
|||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
required: false
|
required: false
|
||||||
debug:
|
debug:
|
||||||
description: Whether to tell the GitHub client to log details of its requests
|
description: Whether to tell the GitHub client to log details of its requests. true or false. Default is to run in debug mode when the GitHub Actions step debug logging is turned on.
|
||||||
default: false
|
default: ${{ runner.debug == '1' }}
|
||||||
user-agent:
|
user-agent:
|
||||||
description: An optional user-agent string
|
description: An optional user-agent string
|
||||||
default: actions/github-script
|
default: actions/github-script
|
||||||
|
|||||||
Vendored
+56
-18
@@ -6542,6 +6542,45 @@ exports.paginatingEndpoints = paginatingEndpoints;
|
|||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8883:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
var __webpack_unused_export__;
|
||||||
|
|
||||||
|
|
||||||
|
__webpack_unused_export__ = ({ value: true });
|
||||||
|
|
||||||
|
const VERSION = "1.0.4";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param octokit Octokit instance
|
||||||
|
* @param options Options passed to Octokit constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
function requestLog(octokit) {
|
||||||
|
octokit.hook.wrap("request", (request, options) => {
|
||||||
|
octokit.log.debug("request", options);
|
||||||
|
const start = Date.now();
|
||||||
|
const requestOptions = octokit.request.endpoint.parse(options);
|
||||||
|
const path = requestOptions.url.replace(options.baseUrl, "");
|
||||||
|
return request(options).then(response => {
|
||||||
|
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);
|
||||||
|
return response;
|
||||||
|
}).catch(error => {
|
||||||
|
octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
requestLog.VERSION = VERSION;
|
||||||
|
|
||||||
|
exports.g = requestLog;
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6298:
|
/***/ 6298:
|
||||||
@@ -15091,8 +15130,13 @@ var utils = __nccwpck_require__(3030);
|
|||||||
var glob = __nccwpck_require__(8090);
|
var glob = __nccwpck_require__(8090);
|
||||||
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
|
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
|
||||||
var io = __nccwpck_require__(7436);
|
var io = __nccwpck_require__(7436);
|
||||||
|
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-request-log/dist-node/index.js
|
||||||
|
var dist_node = __nccwpck_require__(8883);
|
||||||
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-retry/dist-node/index.js
|
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-retry/dist-node/index.js
|
||||||
var dist_node = __nccwpck_require__(6298);
|
var plugin_retry_dist_node = __nccwpck_require__(6298);
|
||||||
|
// EXTERNAL MODULE: ./node_modules/node-fetch/lib/index.js
|
||||||
|
var lib = __nccwpck_require__(467);
|
||||||
|
var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib);
|
||||||
;// CONCATENATED MODULE: ./src/async-function.ts
|
;// CONCATENATED MODULE: ./src/async-function.ts
|
||||||
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
|
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
|
||||||
function callAsyncFunction(args, source) {
|
function callAsyncFunction(args, source) {
|
||||||
@@ -15120,7 +15164,7 @@ function getRetryOptions(retries, exemptStatusCodes, defaultOptions) {
|
|||||||
...defaultOptions.request,
|
...defaultOptions.request,
|
||||||
retries
|
retries
|
||||||
};
|
};
|
||||||
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]'})`);
|
core.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : 'octokit default: [400, 401, 403, 404, 422]'})`);
|
||||||
return [retryOptions, requestOptions];
|
return [retryOptions, requestOptions];
|
||||||
}
|
}
|
||||||
function parseNumberArray(listString) {
|
function parseNumberArray(listString) {
|
||||||
@@ -15156,9 +15200,6 @@ const wrapRequire = new Proxy(require, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// EXTERNAL MODULE: ./node_modules/node-fetch/lib/index.js
|
|
||||||
var lib = __nccwpck_require__(467);
|
|
||||||
var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib);
|
|
||||||
;// CONCATENATED MODULE: ./src/main.ts
|
;// CONCATENATED MODULE: ./src/main.ts
|
||||||
|
|
||||||
|
|
||||||
@@ -15171,28 +15212,25 @@ var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process.on('unhandledRejection', handleError);
|
process.on('unhandledRejection', handleError);
|
||||||
main().catch(handleError);
|
main().catch(handleError);
|
||||||
async function main() {
|
async function main() {
|
||||||
const token = core.getInput('github-token', { required: true });
|
const token = core.getInput('github-token', { required: true });
|
||||||
const debug = core.getInput('debug');
|
const debug = core.getBooleanInput('debug');
|
||||||
const userAgent = core.getInput('user-agent');
|
const userAgent = core.getInput('user-agent');
|
||||||
const previews = core.getInput('previews');
|
const previews = core.getInput('previews');
|
||||||
const retries = parseInt(core.getInput('retries'));
|
const retries = parseInt(core.getInput('retries'));
|
||||||
const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes'));
|
const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes'));
|
||||||
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults);
|
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults);
|
||||||
const opts = {};
|
const opts = {
|
||||||
if (debug === 'true')
|
log: debug ? console : undefined,
|
||||||
opts.log = console;
|
userAgent: userAgent || undefined,
|
||||||
if (userAgent != null)
|
previews: previews ? previews.split(',') : undefined,
|
||||||
opts.userAgent = userAgent;
|
retry: retryOpts,
|
||||||
if (previews != null)
|
request: requestOpts
|
||||||
opts.previews = previews.split(',');
|
};
|
||||||
if (retryOpts)
|
const github = (0,lib_github.getOctokit)(token, opts, plugin_retry_dist_node/* retry */.XD, dist_node/* requestLog */.g);
|
||||||
opts.retry = retryOpts;
|
|
||||||
if (requestOpts)
|
|
||||||
opts.request = requestOpts;
|
|
||||||
const github = (0,lib_github.getOctokit)(token, opts, dist_node/* retry */.XD);
|
|
||||||
const script = core.getInput('script', { required: true });
|
const script = core.getInput('script', { required: true });
|
||||||
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
||||||
const result = await callAsyncFunction({
|
const result = await callAsyncFunction({
|
||||||
|
|||||||
Generated
+10
-49
@@ -15,8 +15,7 @@
|
|||||||
"@actions/glob": "^0.3.0",
|
"@actions/glob": "^0.3.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.1",
|
||||||
"@octokit/core": "^3.5.1",
|
"@octokit/core": "^3.5.1",
|
||||||
"@octokit/plugin-paginate-rest": "^2.17.0",
|
"@octokit/plugin-request-log": "^1.0.4",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^6.3.0",
|
|
||||||
"@octokit/plugin-retry": "^3.0.9",
|
"@octokit/plugin-retry": "^3.0.9",
|
||||||
"node-fetch": "^2.6.7"
|
"node-fetch": "^2.6.7"
|
||||||
},
|
},
|
||||||
@@ -1125,34 +1124,14 @@
|
|||||||
"@octokit/core": ">=2"
|
"@octokit/core": ">=2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/plugin-rest-endpoint-methods": {
|
"node_modules/@octokit/plugin-request-log": {
|
||||||
"version": "6.3.0",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz",
|
||||||
"integrity": "sha512-qEu2wn6E7hqluZwIEUnDxWROvKjov3zMIAi4H4d7cmKWNMeBprEXZzJe8pE5eStUYC1ysGhD0B7L6IeG1Rfb+g==",
|
"integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==",
|
||||||
"dependencies": {
|
|
||||||
"@octokit/types": "^7.0.0",
|
|
||||||
"deprecation": "^2.3.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 14"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@octokit/core": ">=3"
|
"@octokit/core": ">=3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": {
|
|
||||||
"version": "13.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-13.2.0.tgz",
|
|
||||||
"integrity": "sha512-1BhjsVrCe2cyE36Rorpeq331bcYzdb9ksCpkFdAN6RVtW67YdO3Pl4YXDC5dF2D1ia76MssJdn5RV+Gj9Fu7dQ=="
|
|
||||||
},
|
|
||||||
"node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-+ClA0jRc9zGFj5mfQeQNfgTlelzhpAexbAueQG1t2Xn8yhgnsjkF8bgLcUUpwrpqkv296uXyiGwkqXRSU7KYzQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"@octokit/openapi-types": "^13.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@octokit/plugin-retry": {
|
"node_modules/@octokit/plugin-retry": {
|
||||||
"version": "3.0.9",
|
"version": "3.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.9.tgz",
|
||||||
@@ -7092,29 +7071,11 @@
|
|||||||
"@octokit/types": "^6.34.0"
|
"@octokit/types": "^6.34.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@octokit/plugin-rest-endpoint-methods": {
|
"@octokit/plugin-request-log": {
|
||||||
"version": "6.3.0",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz",
|
||||||
"integrity": "sha512-qEu2wn6E7hqluZwIEUnDxWROvKjov3zMIAi4H4d7cmKWNMeBprEXZzJe8pE5eStUYC1ysGhD0B7L6IeG1Rfb+g==",
|
"integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==",
|
||||||
"requires": {
|
"requires": {}
|
||||||
"@octokit/types": "^7.0.0",
|
|
||||||
"deprecation": "^2.3.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@octokit/openapi-types": {
|
|
||||||
"version": "13.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-13.2.0.tgz",
|
|
||||||
"integrity": "sha512-1BhjsVrCe2cyE36Rorpeq331bcYzdb9ksCpkFdAN6RVtW67YdO3Pl4YXDC5dF2D1ia76MssJdn5RV+Gj9Fu7dQ=="
|
|
||||||
},
|
|
||||||
"@octokit/types": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-+ClA0jRc9zGFj5mfQeQNfgTlelzhpAexbAueQG1t2Xn8yhgnsjkF8bgLcUUpwrpqkv296uXyiGwkqXRSU7KYzQ==",
|
|
||||||
"requires": {
|
|
||||||
"@octokit/openapi-types": "^13.1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"@octokit/plugin-retry": {
|
"@octokit/plugin-retry": {
|
||||||
"version": "3.0.9",
|
"version": "3.0.9",
|
||||||
|
|||||||
+1
-2
@@ -37,8 +37,7 @@
|
|||||||
"@actions/glob": "^0.3.0",
|
"@actions/glob": "^0.3.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.1",
|
||||||
"@octokit/core": "^3.5.1",
|
"@octokit/core": "^3.5.1",
|
||||||
"@octokit/plugin-paginate-rest": "^2.17.0",
|
"@octokit/plugin-request-log": "^1.0.4",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^6.3.0",
|
|
||||||
"@octokit/plugin-retry": "^3.0.9",
|
"@octokit/plugin-retry": "^3.0.9",
|
||||||
"node-fetch": "^2.6.7"
|
"node-fetch": "^2.6.7"
|
||||||
},
|
},
|
||||||
|
|||||||
+13
-11
@@ -4,12 +4,13 @@ import {context, getOctokit} from '@actions/github'
|
|||||||
import {defaults as defaultGitHubOptions} from '@actions/github/lib/utils'
|
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 {requestLog} from '@octokit/plugin-request-log'
|
||||||
import {retry} from '@octokit/plugin-retry'
|
import {retry} from '@octokit/plugin-retry'
|
||||||
import {RequestRequestOptions} from '@octokit/types'
|
import {RequestRequestOptions} from '@octokit/types'
|
||||||
import {callAsyncFunction} from './async-function'
|
|
||||||
import {getRetryOptions, parseNumberArray, RetryOptions} from './retry-options'
|
|
||||||
import {wrapRequire} from './wrap-require'
|
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
import {callAsyncFunction} from './async-function'
|
||||||
|
import {RetryOptions, getRetryOptions, parseNumberArray} from './retry-options'
|
||||||
|
import {wrapRequire} from './wrap-require'
|
||||||
|
|
||||||
process.on('unhandledRejection', handleError)
|
process.on('unhandledRejection', handleError)
|
||||||
main().catch(handleError)
|
main().catch(handleError)
|
||||||
@@ -24,7 +25,7 @@ type Options = {
|
|||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const token = core.getInput('github-token', {required: true})
|
const token = core.getInput('github-token', {required: true})
|
||||||
const debug = core.getInput('debug')
|
const debug = core.getBooleanInput('debug')
|
||||||
const userAgent = core.getInput('user-agent')
|
const userAgent = core.getInput('user-agent')
|
||||||
const previews = core.getInput('previews')
|
const previews = core.getInput('previews')
|
||||||
const retries = parseInt(core.getInput('retries'))
|
const retries = parseInt(core.getInput('retries'))
|
||||||
@@ -37,14 +38,15 @@ async function main(): Promise<void> {
|
|||||||
defaultGitHubOptions
|
defaultGitHubOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
const opts: Options = {}
|
const opts: Options = {
|
||||||
if (debug === 'true') opts.log = console
|
log: debug ? console : undefined,
|
||||||
if (userAgent != null) opts.userAgent = userAgent
|
userAgent: userAgent || undefined,
|
||||||
if (previews != null) opts.previews = previews.split(',')
|
previews: previews ? previews.split(',') : undefined,
|
||||||
if (retryOpts) opts.retry = retryOpts
|
retry: retryOpts,
|
||||||
if (requestOpts) opts.request = requestOpts
|
request: requestOpts
|
||||||
|
}
|
||||||
|
|
||||||
const github = getOctokit(token, opts, retry)
|
const github = getOctokit(token, opts, retry, requestLog)
|
||||||
const script = core.getInput('script', {required: true})
|
const script = core.getInput('script', {required: true})
|
||||||
|
|
||||||
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function getRetryOptions(
|
|||||||
`GitHub client configured with: (retries: ${
|
`GitHub client configured with: (retries: ${
|
||||||
requestOptions.retries
|
requestOptions.retries
|
||||||
}, retry-exempt-status-code: ${
|
}, retry-exempt-status-code: ${
|
||||||
retryOptions?.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]'
|
retryOptions.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]'
|
||||||
})`
|
})`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": []
|
||||||
|
}
|
||||||
Reference in new issue
Block a user