mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-30 10:04:53 +00:00
Compare commits
8 Commits
v2.0.2
...
error-coun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7b5c1034e | ||
|
|
b4d15f6490 | ||
|
|
c883148031 | ||
|
|
b1a18fc1bd | ||
|
|
80d8f1cab8 | ||
|
|
ffdf102557 | ||
|
|
a1b3914731 | ||
|
|
a378718509 |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 79.72%"><title>Coverage: 79.72%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#e05d44"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">79.72%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">79.72%</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 80.18%"><title>Coverage: 80.18%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#dfb317"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">80.18%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">80.18%</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
121
dist/index.js
generated
vendored
121
dist/index.js
generated
vendored
@@ -4093,28 +4093,51 @@ exports.restEndpointMethods = restEndpointMethods;
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 537:
|
/***/ 537:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __create = Object.create;
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __getProtoOf = Object.getPrototypeOf;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||||
|
// If the importer is in node compatibility mode or this is not an ESM
|
||||||
|
// file that has been converted to a CommonJS file using a Babel-
|
||||||
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||||
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||||
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||||
|
mod
|
||||||
|
));
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
// pkg/dist-src/index.js
|
||||||
|
var dist_src_exports = {};
|
||||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
__export(dist_src_exports, {
|
||||||
|
RequestError: () => RequestError
|
||||||
var deprecation = __nccwpck_require__(8932);
|
});
|
||||||
var once = _interopDefault(__nccwpck_require__(1223));
|
module.exports = __toCommonJS(dist_src_exports);
|
||||||
|
var import_deprecation = __nccwpck_require__(8932);
|
||||||
const logOnceCode = once(deprecation => console.warn(deprecation));
|
var import_once = __toESM(__nccwpck_require__(1223));
|
||||||
const logOnceHeaders = once(deprecation => console.warn(deprecation));
|
var logOnceCode = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||||||
/**
|
var logOnceHeaders = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||||||
* Error with extra properties to help with debugging
|
var RequestError = class extends Error {
|
||||||
*/
|
|
||||||
class RequestError extends Error {
|
|
||||||
constructor(message, statusCode, options) {
|
constructor(message, statusCode, options) {
|
||||||
super(message);
|
super(message);
|
||||||
// Maintains proper stack trace (only available on V8)
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (Error.captureStackTrace) {
|
if (Error.captureStackTrace) {
|
||||||
Error.captureStackTrace(this, this.constructor);
|
Error.captureStackTrace(this, this.constructor);
|
||||||
}
|
}
|
||||||
@@ -4128,39 +4151,41 @@ class RequestError extends Error {
|
|||||||
this.response = options.response;
|
this.response = options.response;
|
||||||
headers = options.response.headers;
|
headers = options.response.headers;
|
||||||
}
|
}
|
||||||
// redact request credentials without mutating original request options
|
|
||||||
const requestCopy = Object.assign({}, options.request);
|
const requestCopy = Object.assign({}, options.request);
|
||||||
if (options.request.headers.authorization) {
|
if (options.request.headers.authorization) {
|
||||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
|
authorization: options.request.headers.authorization.replace(
|
||||||
|
/ .*$/,
|
||||||
|
" [REDACTED]"
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
requestCopy.url = requestCopy.url
|
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||||
// client_id & client_secret can be passed as URL query parameters to increase rate limit
|
|
||||||
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
|
||||||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]")
|
|
||||||
// OAuth tokens can be passed as URL query parameters, although it is not recommended
|
|
||||||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
|
||||||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
||||||
this.request = requestCopy;
|
this.request = requestCopy;
|
||||||
// deprecations
|
|
||||||
Object.defineProperty(this, "code", {
|
Object.defineProperty(this, "code", {
|
||||||
get() {
|
get() {
|
||||||
logOnceCode(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
logOnceCode(
|
||||||
|
new import_deprecation.Deprecation(
|
||||||
|
"[@octokit/request-error] `error.code` is deprecated, use `error.status`."
|
||||||
|
)
|
||||||
|
);
|
||||||
return statusCode;
|
return statusCode;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, "headers", {
|
Object.defineProperty(this, "headers", {
|
||||||
get() {
|
get() {
|
||||||
logOnceHeaders(new deprecation.Deprecation("[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`."));
|
logOnceHeaders(
|
||||||
|
new import_deprecation.Deprecation(
|
||||||
|
"[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`."
|
||||||
|
)
|
||||||
|
);
|
||||||
return headers || {};
|
return headers || {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
exports.RequestError = RequestError;
|
0 && (0);
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -10055,21 +10080,32 @@ class Deployment {
|
|||||||
this.isPreview = context.isPreview === true
|
this.isPreview = context.isPreview === true
|
||||||
this.timeout = MAX_TIMEOUT
|
this.timeout = MAX_TIMEOUT
|
||||||
this.startTime = null
|
this.startTime = null
|
||||||
|
this.maxErrorCount = null
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptionalUserInput() {
|
||||||
|
const timeoutInput = Number(core.getInput('timeout'))
|
||||||
|
if (timeoutInput > MAX_TIMEOUT) {
|
||||||
|
core.warning(
|
||||||
|
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
||||||
|
|
||||||
|
const maxErrorCountInput = Number(core.getInput('error_count'))
|
||||||
|
if (!maxErrorCountInput || maxErrorCountInput <= 0) {
|
||||||
|
core.warning('Invalid error_count value will be ignored. Please ensure the value is a positive integer.')
|
||||||
|
} else {
|
||||||
|
this.maxErrorCount = maxErrorCountInput
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
// by creating a deployment with that artifact
|
// by creating a deployment with that artifact
|
||||||
async create(idToken) {
|
async create(idToken) {
|
||||||
if (Number(core.getInput('timeout')) > MAX_TIMEOUT) {
|
|
||||||
core.warning(
|
|
||||||
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeoutInput = Number(core.getInput('timeout'))
|
|
||||||
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.setOptionalUserInput()
|
||||||
|
|
||||||
core.debug(`Actor: ${this.buildActor}`)
|
core.debug(`Actor: ${this.buildActor}`)
|
||||||
core.debug(`Action ID: ${this.actionsId}`)
|
core.debug(`Action ID: ${this.actionsId}`)
|
||||||
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
||||||
@@ -10155,7 +10191,6 @@ class Deployment {
|
|||||||
|
|
||||||
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
|
|
||||||
let errorCount = 0
|
let errorCount = 0
|
||||||
|
|
||||||
@@ -10214,7 +10249,7 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= this.maxErrorCount) {
|
||||||
core.error('Too many errors, aborting!')
|
core.error('Too many errors, aborting!')
|
||||||
core.setFailed('Failed with status code: ' + errorStatus)
|
core.setFailed('Failed with status code: ' + errorStatus)
|
||||||
|
|
||||||
|
|||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
16
package-lock.json
generated
16
package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@actions/http-client": "^2.1.0",
|
"@actions/http-client": "^2.1.0",
|
||||||
"@octokit/request-error": "^3.0.3",
|
"@octokit/request-error": "^4.0.1",
|
||||||
"http-status-messages": "^1.1.0"
|
"http-status-messages": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1329,16 +1329,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/request-error": {
|
"node_modules/@octokit/request-error": {
|
||||||
"version": "3.0.3",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-4.0.1.tgz",
|
||||||
"integrity": "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==",
|
"integrity": "sha512-DBTkqzs0K6SlK1gRaQ6A6yOnKKkbVy8n/A9E7Es5qYONIxBghqiETPqWhG9l7qvWgp8v3sDkB8vlV2AAX1N6gw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@octokit/types": "^9.0.0",
|
"@octokit/types": "^9.0.0",
|
||||||
"deprecation": "^2.0.0",
|
"deprecation": "^2.0.0",
|
||||||
"once": "^1.4.0"
|
"once": "^1.4.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": {
|
"node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": {
|
||||||
@@ -7437,9 +7437,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@octokit/request-error": {
|
"@octokit/request-error": {
|
||||||
"version": "3.0.3",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-4.0.1.tgz",
|
||||||
"integrity": "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==",
|
"integrity": "sha512-DBTkqzs0K6SlK1gRaQ6A6yOnKKkbVy8n/A9E7Es5qYONIxBghqiETPqWhG9l7qvWgp8v3sDkB8vlV2AAX1N6gw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@octokit/types": "^9.0.0",
|
"@octokit/types": "^9.0.0",
|
||||||
"deprecation": "^2.0.0",
|
"deprecation": "^2.0.0",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@actions/http-client": "^2.1.0",
|
"@actions/http-client": "^2.1.0",
|
||||||
"@octokit/request-error": "^3.0.3",
|
"@octokit/request-error": "^4.0.1",
|
||||||
"http-status-messages": "^1.1.0"
|
"http-status-messages": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -44,6 +44,101 @@ describe('Deployment', () => {
|
|||||||
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('#setOptionalUserInput', () => {
|
||||||
|
it('warns when the timeout is greater than the maximum allowed', async () => {
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
|
switch (param) {
|
||||||
|
case 'timeout':
|
||||||
|
return MAX_TIMEOUT + 1
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput()
|
||||||
|
|
||||||
|
expect(deployment.timeout).toBe(MAX_TIMEOUT)
|
||||||
|
expect(core.warning).toBeCalledWith(
|
||||||
|
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the error_count input when valid', async () => {
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
|
switch (param) {
|
||||||
|
case 'error_count':
|
||||||
|
return '1'
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Create the deployment
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput()
|
||||||
|
|
||||||
|
expect(deployment.maxErrorCount).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the error_count input to null if zero and warns user', async () => {
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
|
switch (param) {
|
||||||
|
case 'error_count':
|
||||||
|
return '0'
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput()
|
||||||
|
|
||||||
|
expect(deployment.maxErrorCount).toBe(null)
|
||||||
|
expect(core.warning).toHaveBeenCalledWith(
|
||||||
|
'Invalid error_count value will be ignored. Please ensure the value is a positive integer.'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the error_count input to null if negative and warns user', async () => {
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
|
switch (param) {
|
||||||
|
case 'error_count':
|
||||||
|
return '-1'
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput()
|
||||||
|
|
||||||
|
expect(deployment.maxErrorCount).toBe(null)
|
||||||
|
expect(core.warning).toHaveBeenCalledWith(
|
||||||
|
'Invalid error_count value will be ignored. Please ensure the value is a positive integer.'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the error_count input to null if not a number and warns user', async () => {
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
|
switch (param) {
|
||||||
|
case 'error_count':
|
||||||
|
return 'not a number'
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput()
|
||||||
|
|
||||||
|
expect(deployment.maxErrorCount).toBe(null)
|
||||||
|
expect(core.warning).toHaveBeenCalledWith(
|
||||||
|
'Invalid error_count value will be ignored. Please ensure the value is a positive integer.'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('#create', () => {
|
describe('#create', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// Remove mock for `core.getInput('preview')`
|
// Remove mock for `core.getInput('preview')`
|
||||||
@@ -88,6 +183,42 @@ describe('Deployment', () => {
|
|||||||
createDeploymentScope.done()
|
createDeploymentScope.done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('invokes #setOptionalUserInput', async () => {
|
||||||
|
process.env.GITHUB_SHA = 'valid-build-version'
|
||||||
|
|
||||||
|
const artifactExchangeScope = nock(`http://my-url`)
|
||||||
|
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
|
||||||
|
.reply(200, {
|
||||||
|
value: [
|
||||||
|
{ url: 'https://another-artifact.com', name: 'another-artifact' },
|
||||||
|
{ url: 'https://fake-artifact.com', name: 'github-pages' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const createDeploymentScope = nock('https://api.github.com')
|
||||||
|
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
|
||||||
|
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
|
||||||
|
pages_build_version: process.env.GITHUB_SHA,
|
||||||
|
oidc_token: fakeJwt
|
||||||
|
})
|
||||||
|
.reply(200, {
|
||||||
|
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
|
||||||
|
page_url: 'https://actions.github.io/is-awesome'
|
||||||
|
})
|
||||||
|
|
||||||
|
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
||||||
|
|
||||||
|
// Create the deployment
|
||||||
|
const deployment = new Deployment()
|
||||||
|
deployment.setOptionalUserInput = jest.fn()
|
||||||
|
await deployment.create(fakeJwt)
|
||||||
|
|
||||||
|
expect(deployment.setOptionalUserInput).toHaveBeenCalled()
|
||||||
|
|
||||||
|
artifactExchangeScope.done()
|
||||||
|
createDeploymentScope.done()
|
||||||
|
})
|
||||||
|
|
||||||
it('can successfully create a preview deployment', async () => {
|
it('can successfully create a preview deployment', async () => {
|
||||||
process.env.GITHUB_SHA = 'valid-build-version'
|
process.env.GITHUB_SHA = 'valid-build-version'
|
||||||
|
|
||||||
@@ -587,7 +718,6 @@ describe('Deployment', () => {
|
|||||||
|
|
||||||
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
||||||
|
|
||||||
// Set timeout to great than max
|
|
||||||
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
jest.spyOn(core, 'getInput').mockImplementation(param => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'artifact_name':
|
case 'artifact_name':
|
||||||
|
|||||||
@@ -45,21 +45,32 @@ class Deployment {
|
|||||||
this.isPreview = context.isPreview === true
|
this.isPreview = context.isPreview === true
|
||||||
this.timeout = MAX_TIMEOUT
|
this.timeout = MAX_TIMEOUT
|
||||||
this.startTime = null
|
this.startTime = null
|
||||||
|
this.maxErrorCount = null
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptionalUserInput() {
|
||||||
|
const timeoutInput = Number(core.getInput('timeout'))
|
||||||
|
if (timeoutInput > MAX_TIMEOUT) {
|
||||||
|
core.warning(
|
||||||
|
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
||||||
|
|
||||||
|
const maxErrorCountInput = Number(core.getInput('error_count'))
|
||||||
|
if (!maxErrorCountInput || maxErrorCountInput <= 0) {
|
||||||
|
core.warning('Invalid error_count value will be ignored. Please ensure the value is a positive integer.')
|
||||||
|
} else {
|
||||||
|
this.maxErrorCount = maxErrorCountInput
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
// by creating a deployment with that artifact
|
// by creating a deployment with that artifact
|
||||||
async create(idToken) {
|
async create(idToken) {
|
||||||
if (Number(core.getInput('timeout')) > MAX_TIMEOUT) {
|
|
||||||
core.warning(
|
|
||||||
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeoutInput = Number(core.getInput('timeout'))
|
|
||||||
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.setOptionalUserInput()
|
||||||
|
|
||||||
core.debug(`Actor: ${this.buildActor}`)
|
core.debug(`Actor: ${this.buildActor}`)
|
||||||
core.debug(`Action ID: ${this.actionsId}`)
|
core.debug(`Action ID: ${this.actionsId}`)
|
||||||
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
||||||
@@ -145,7 +156,6 @@ class Deployment {
|
|||||||
|
|
||||||
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
|
|
||||||
let errorCount = 0
|
let errorCount = 0
|
||||||
|
|
||||||
@@ -204,7 +214,7 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= this.maxErrorCount) {
|
||||||
core.error('Too many errors, aborting!')
|
core.error('Too many errors, aborting!')
|
||||||
core.setFailed('Failed with status code: ' + errorStatus)
|
core.setFailed('Failed with status code: ' + errorStatus)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user