mirror of
https://github.com/actions/deploy-pages.git
synced 2025-12-08 08:06:15 +00:00
Add support for preview deployments
This commit is contained in:
@@ -12,7 +12,8 @@ function getRequiredVars() {
|
||||
actionsId: process.env.GITHUB_ACTION,
|
||||
githubToken: core.getInput('token'),
|
||||
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
||||
artifactName: core.getInput('artifact_name') ?? 'github-pages'
|
||||
artifactName: core.getInput('artifact_name') ?? 'github-pages',
|
||||
isPreview: core.getInput('preview') === 'true'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class Deployment {
|
||||
this.deploymentInfo = null
|
||||
this.githubApiUrl = context.githubApiUrl
|
||||
this.artifactName = context.artifactName
|
||||
this.isPreview = context.isPreview === true
|
||||
}
|
||||
|
||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||
@@ -58,6 +59,9 @@ class Deployment {
|
||||
pages_build_version: this.buildVersion,
|
||||
oidc_token: idToken
|
||||
}
|
||||
if (this.isPreview === true) {
|
||||
payload.preview = true
|
||||
}
|
||||
core.info(`Creating deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
|
||||
const response = await axios.post(pagesDeployEndpoint, payload, {
|
||||
headers: {
|
||||
@@ -110,7 +114,12 @@ class Deployment {
|
||||
this.deploymentInfo != null
|
||||
? this.deploymentInfo['status_url']
|
||||
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo['page_url'] : '')
|
||||
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 reportingInterval = Number(core.getInput('reporting_interval'))
|
||||
const maxErrorCount = Number(core.getInput('error_count'))
|
||||
|
||||
Reference in New Issue
Block a user