mirror of
https://github.com/actions/deploy-pages.git
synced 2025-12-09 00:26:14 +00:00
enforce a max timeout
This commit is contained in:
28
dist/index.js
generated
vendored
28
dist/index.js
generated
vendored
@@ -10041,6 +10041,8 @@ class Deployment {
|
||||
this.githubServerUrl = context.githubServerUrl
|
||||
this.artifactName = context.artifactName
|
||||
this.isPreview = context.isPreview === true
|
||||
this.timeout = maxTimeout
|
||||
this.startTime = null
|
||||
}
|
||||
|
||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||
@@ -10052,6 +10054,9 @@ class Deployment {
|
||||
)
|
||||
}
|
||||
|
||||
let timeoutInput = Number(core.getInput('timeout'))
|
||||
this.timeout = timeoutInput <= 0 ? maxTimeout : Math.min(timeoutInput, maxTimeout)
|
||||
|
||||
try {
|
||||
core.debug(`Actor: ${this.buildActor}`)
|
||||
core.debug(`Action ID: ${this.actionsId}`)
|
||||
@@ -10077,6 +10082,7 @@ class Deployment {
|
||||
id: deployment.id || deployment.status_url?.split('/')?.pop() || this.buildVersion,
|
||||
pending: true
|
||||
}
|
||||
this.startTime = Date.now()
|
||||
}
|
||||
|
||||
core.info(`Created deployment for ${this.buildVersion}, ID: ${this.deploymentInfo?.id}`)
|
||||
@@ -10125,11 +10131,9 @@ class Deployment {
|
||||
}
|
||||
|
||||
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
||||
const timeout = Number(core.getInput('timeout'))
|
||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||
const maxErrorCount = Number(core.getInput('error_count'))
|
||||
|
||||
let startTime = Date.now()
|
||||
let errorCount = 0
|
||||
|
||||
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||
@@ -10139,6 +10143,16 @@ class Deployment {
|
||||
|
||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||
while (true) {
|
||||
// Handle timeout
|
||||
if (Date.now() - this.startTime >= this.timeout) {
|
||||
core.error('Timeout reached, aborting!')
|
||||
core.setFailed('Timeout reached, aborting!')
|
||||
|
||||
// Explicitly cancel the deployment
|
||||
await this.cancel()
|
||||
return
|
||||
}
|
||||
|
||||
// Handle reporting interval
|
||||
await new Promise(resolve => setTimeout(resolve, reportingInterval + errorReportingInterval))
|
||||
|
||||
@@ -10195,16 +10209,6 @@ class Deployment {
|
||||
await this.cancel()
|
||||
return
|
||||
}
|
||||
|
||||
// Handle timeout
|
||||
if (Date.now() - startTime >= timeout) {
|
||||
core.error('Timeout reached, aborting!')
|
||||
core.setFailed('Timeout reached, aborting!')
|
||||
|
||||
// Explicitly cancel the deployment
|
||||
await this.cancel()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
Reference in New Issue
Block a user