mirror of
https://github.com/actions/deploy-pages.git
synced 2025-12-08 16:16:16 +00:00
add error interval with some error specification
This commit is contained in:
35
dist/index.js
vendored
35
dist/index.js
vendored
@@ -7050,6 +7050,12 @@ const axios = __nccwpck_require__(6545)
|
|||||||
// All variables we need from the runtime are loaded here
|
// All variables we need from the runtime are loaded here
|
||||||
const getContext = __nccwpck_require__(1319)
|
const getContext = __nccwpck_require__(1319)
|
||||||
|
|
||||||
|
const errorStatus = {
|
||||||
|
'unknown_status' : 'Unable to get deployment status.',
|
||||||
|
'not_found' : 'Deployment not found.',
|
||||||
|
'deployment_attempt_error' : 'Deployment temporarily failed, a retry will be automatically scheduled...'
|
||||||
|
}
|
||||||
|
|
||||||
class Deployment {
|
class Deployment {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
@@ -7120,17 +7126,19 @@ class Deployment {
|
|||||||
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
||||||
const timeout = core.getInput('timeout')
|
const timeout = core.getInput('timeout')
|
||||||
const reportingInterval = core.getInput('reporting_interval')
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = core.getInput('error_count')
|
const maxErrorCount = core.getInput('error_count')
|
||||||
var startTime = Date.now()
|
var startTime = Date.now()
|
||||||
var errorCount = 0
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
// Handle reporting interval
|
// Handle reporting interval
|
||||||
if (reportingInterval > 0) {
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
await new Promise(r => setTimeout(r, reportingInterval))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check status
|
// Check status
|
||||||
var res = await axios.get(statusUrl, {
|
var res = await axios.get(statusUrl, {
|
||||||
@@ -7151,17 +7159,23 @@ class Deployment {
|
|||||||
// The uploaded artifact is invalid.
|
// The uploaded artifact is invalid.
|
||||||
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
||||||
break
|
break
|
||||||
} else if (res.data.status == 'deployment_attempt_error') {
|
} else if (errorStatus[res.data.status]) {
|
||||||
// A temporary error happened, a retry will be scheduled automatically.
|
// A temporary error happened, will query the status again
|
||||||
core.info(
|
core.info(errorStatus[res.data.status])
|
||||||
'Deployment temporarily failed, a retry will be automatically scheduled...'
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
core.info('Current status: ' + res.data.status)
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status != 200) {
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
errorCount++
|
errorCount++
|
||||||
|
|
||||||
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = errorReportingInterval << 1 | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= maxErrorCount) {
|
||||||
@@ -7184,7 +7198,6 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {Deployment}
|
module.exports = {Deployment}
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
35
pre/index.js
35
pre/index.js
@@ -7050,6 +7050,12 @@ const axios = __nccwpck_require__(6545)
|
|||||||
// All variables we need from the runtime are loaded here
|
// All variables we need from the runtime are loaded here
|
||||||
const getContext = __nccwpck_require__(1319)
|
const getContext = __nccwpck_require__(1319)
|
||||||
|
|
||||||
|
const errorStatus = {
|
||||||
|
'unknown_status' : 'Unable to get deployment status.',
|
||||||
|
'not_found' : 'Deployment not found.',
|
||||||
|
'deployment_attempt_error' : 'Deployment temporarily failed, a retry will be automatically scheduled...'
|
||||||
|
}
|
||||||
|
|
||||||
class Deployment {
|
class Deployment {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
@@ -7120,17 +7126,19 @@ class Deployment {
|
|||||||
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
||||||
const timeout = core.getInput('timeout')
|
const timeout = core.getInput('timeout')
|
||||||
const reportingInterval = core.getInput('reporting_interval')
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = core.getInput('error_count')
|
const maxErrorCount = core.getInput('error_count')
|
||||||
var startTime = Date.now()
|
var startTime = Date.now()
|
||||||
var errorCount = 0
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
// Handle reporting interval
|
// Handle reporting interval
|
||||||
if (reportingInterval > 0) {
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
await new Promise(r => setTimeout(r, reportingInterval))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check status
|
// Check status
|
||||||
var res = await axios.get(statusUrl, {
|
var res = await axios.get(statusUrl, {
|
||||||
@@ -7151,17 +7159,23 @@ class Deployment {
|
|||||||
// The uploaded artifact is invalid.
|
// The uploaded artifact is invalid.
|
||||||
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
||||||
break
|
break
|
||||||
} else if (res.data.status == 'deployment_attempt_error') {
|
} else if (errorStatus[res.data.status]) {
|
||||||
// A temporary error happened, a retry will be scheduled automatically.
|
// A temporary error happened, will query the status again
|
||||||
core.info(
|
core.info(errorStatus[res.data.status])
|
||||||
'Deployment temporarily failed, a retry will be automatically scheduled...'
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
core.info('Current status: ' + res.data.status)
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status != 200) {
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
errorCount++
|
errorCount++
|
||||||
|
|
||||||
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = errorReportingInterval << 1 | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= maxErrorCount) {
|
||||||
@@ -7184,7 +7198,6 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {Deployment}
|
module.exports = {Deployment}
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -6,6 +6,12 @@ const axios = require('axios')
|
|||||||
// All variables we need from the runtime are loaded here
|
// All variables we need from the runtime are loaded here
|
||||||
const getContext = require('./context')
|
const getContext = require('./context')
|
||||||
|
|
||||||
|
const errorStatus = {
|
||||||
|
'unknown_status' : 'Unable to get deployment status.',
|
||||||
|
'not_found' : 'Deployment not found.',
|
||||||
|
'deployment_attempt_error' : 'Deployment temporarily failed, a retry will be automatically scheduled...'
|
||||||
|
}
|
||||||
|
|
||||||
class Deployment {
|
class Deployment {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
@@ -76,17 +82,18 @@ class Deployment {
|
|||||||
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
||||||
const timeout = core.getInput('timeout')
|
const timeout = core.getInput('timeout')
|
||||||
const reportingInterval = core.getInput('reporting_interval')
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = core.getInput('error_count')
|
const maxErrorCount = core.getInput('error_count')
|
||||||
var startTime = Date.now()
|
var startTime = Date.now()
|
||||||
var errorCount = 0
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
while (true) {
|
while (true) {
|
||||||
// Handle reporting interval
|
// Handle reporting interval
|
||||||
if (reportingInterval > 0) {
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
await new Promise(r => setTimeout(r, reportingInterval))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check status
|
// Check status
|
||||||
var res = await axios.get(statusUrl, {
|
var res = await axios.get(statusUrl, {
|
||||||
@@ -107,17 +114,23 @@ class Deployment {
|
|||||||
// The uploaded artifact is invalid.
|
// The uploaded artifact is invalid.
|
||||||
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
||||||
break
|
break
|
||||||
} else if (res.data.status == 'deployment_attempt_error') {
|
} else if (errorStatus[res.data.status]) {
|
||||||
// A temporary error happened, a retry will be scheduled automatically.
|
// A temporary error happened, will query the status again
|
||||||
core.info(
|
core.info(errorStatus[res.data.status])
|
||||||
'Deployment temporarily failed, a retry will be automatically scheduled...'
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
core.info('Current status: ' + res.data.status)
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status != 200) {
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
errorCount++
|
errorCount++
|
||||||
|
|
||||||
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = errorReportingInterval << 1 | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= maxErrorCount) {
|
||||||
@@ -140,5 +153,4 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {Deployment}
|
module.exports = {Deployment}
|
||||||
Reference in New Issue
Block a user