mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-30 10:04:53 +00:00
Move setting 'page_url' output variable to top-level index
This commit is contained in:
@@ -102,12 +102,6 @@ class Deployment {
|
|||||||
this.deploymentInfo != null
|
this.deploymentInfo != null
|
||||||
? this.deploymentInfo['status_url']
|
? this.deploymentInfo['status_url']
|
||||||
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||||
let pageUrl = this.deploymentInfo != null ? this.deploymentInfo['page_url'] : ''
|
|
||||||
const previewUrl = this.deploymentInfo != null ? this.deploymentInfo['preview_url'] : ''
|
|
||||||
if (this.isPreview && previewUrl) {
|
|
||||||
pageUrl = previewUrl
|
|
||||||
}
|
|
||||||
core.setOutput('page_url', pageUrl)
|
|
||||||
const timeout = Number(core.getInput('timeout'))
|
const timeout = Number(core.getInput('timeout'))
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
const maxErrorCount = Number(core.getInput('error_count'))
|
||||||
|
|||||||
17
src/index.js
17
src/index.js
@@ -3,9 +3,10 @@
|
|||||||
// without the user having to do the tar process themselves.
|
// without the user having to do the tar process themselves.
|
||||||
|
|
||||||
const core = require('@actions/core')
|
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 } = require('./deployment')
|
||||||
|
const getContext = require('./context')
|
||||||
|
|
||||||
const deployment = new Deployment()
|
const deployment = new Deployment()
|
||||||
|
|
||||||
async function cancelHandler(evtOrExitCodeOrError) {
|
async function cancelHandler(evtOrExitCodeOrError) {
|
||||||
@@ -14,6 +15,8 @@ async function cancelHandler(evtOrExitCodeOrError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
const { isPreview } = getContext()
|
||||||
|
|
||||||
let idToken = ''
|
let idToken = ''
|
||||||
try {
|
try {
|
||||||
idToken = await core.getIDToken()
|
idToken = await core.getIDToken()
|
||||||
@@ -22,8 +25,18 @@ async function main() {
|
|||||||
core.setFailed(`Ensure GITHUB_TOKEN has permission "id-token: write".`)
|
core.setFailed(`Ensure GITHUB_TOKEN has permission "id-token: write".`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deployment.create(idToken)
|
const deploymentInfo = await deployment.create(idToken)
|
||||||
|
|
||||||
|
// Output the deployed Pages URL
|
||||||
|
let pageUrl = deploymentInfo?.['page_url'] || ''
|
||||||
|
const previewUrl = deploymentInfo?.['preview_url'] || ''
|
||||||
|
if (isPreview && previewUrl) {
|
||||||
|
pageUrl = previewUrl
|
||||||
|
}
|
||||||
|
core.setOutput('page_url', pageUrl)
|
||||||
|
|
||||||
await deployment.check()
|
await deployment.check()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error)
|
core.setFailed(error)
|
||||||
|
|||||||
Reference in New Issue
Block a user