mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-28 17:04:53 +00:00
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
require('regenerator-runtime/runtime')
|
|
|
|
// This package assumes a site has already been built and the files exist in the current workspace
|
|
// If there's an artifact named `artifact.tar`, it can upload that to actions on its own,
|
|
// without the user having to do the tar process themselves.
|
|
|
|
const core = require('@actions/core')
|
|
// const github = require('@actions/github'); // TODO: Not used until we publish API endpoint to the @action/github package
|
|
|
|
const { Deployment } = require('./deployment')
|
|
const deployment = new Deployment()
|
|
|
|
async function cancelHandler(evtOrExitCodeOrError) {
|
|
await deployment.cancel()
|
|
process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError)
|
|
}
|
|
|
|
async function main() {
|
|
let idToken = ''
|
|
try {
|
|
idToken = await core.getIDToken()
|
|
} catch (error) {
|
|
console.log(error)
|
|
core.setFailed(`Ensure GITHUB_TOKEN has permission "idToken: write".`)
|
|
return
|
|
}
|
|
try {
|
|
await deployment.create(idToken)
|
|
await deployment.check()
|
|
} catch (error) {
|
|
core.setFailed(error)
|
|
}
|
|
}
|
|
|
|
// Register signal handlers for workflow cancellation
|
|
process.on('SIGINT', cancelHandler)
|
|
process.on('SIGTERM', cancelHandler)
|
|
|
|
// Main
|
|
const emitTelemetry = core.getInput('emit_telemetry')
|
|
if (emitTelemetry === 'true') {
|
|
require('./pre')
|
|
} else {
|
|
main()
|
|
}
|