Actions staging deployment with Status updates instead of Check Runs (#21283)
* Update Staging deployment workflow to create Status updates * Update local Staging deployment script to create Status updates Co-authored-by: Rachael Sewell <rachmari@github.com>
This commit is contained in:
@@ -147,6 +147,9 @@ async function deployProduction() {
|
||||
}
|
||||
|
||||
async function deployStaging({ owner, repo, pullNumber, forceRebuild = false, destroy = false }) {
|
||||
// Hardcode the Status context name to match Actions
|
||||
const CONTEXT_NAME = 'Staging - Deploy PR / deploy (pull_request)'
|
||||
|
||||
// This helper uses the `GITHUB_TOKEN` implicitly
|
||||
const octokit = getOctokit()
|
||||
|
||||
@@ -163,16 +166,46 @@ async function deployStaging({ owner, repo, pullNumber, forceRebuild = false, de
|
||||
pullRequest,
|
||||
})
|
||||
} else {
|
||||
await octokit.repos.createStatus({
|
||||
owner,
|
||||
repo,
|
||||
sha: pullRequest.head.sha,
|
||||
context: CONTEXT_NAME,
|
||||
state: 'pending',
|
||||
description: 'The app is being deployed. See local logs.',
|
||||
})
|
||||
|
||||
await deployToStaging({
|
||||
octokit,
|
||||
pullRequest,
|
||||
forceRebuild,
|
||||
})
|
||||
|
||||
await octokit.repos.createStatus({
|
||||
owner,
|
||||
repo,
|
||||
sha: pullRequest.head.sha,
|
||||
context: CONTEXT_NAME,
|
||||
state: 'success',
|
||||
description: 'Successfully deployed! See local logs.',
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
const action = destroy ? 'undeploy from' : 'deploy to'
|
||||
console.error(`Failed to ${action} staging: ${error.message}`)
|
||||
console.error(error)
|
||||
|
||||
if (!destroy) {
|
||||
await octokit.repos.createStatus({
|
||||
owner,
|
||||
repo,
|
||||
sha: pullRequest.head.sha,
|
||||
context: CONTEXT_NAME,
|
||||
state: 'error',
|
||||
description: 'Failed to deploy. See local logs.',
|
||||
})
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user