1
0
mirror of synced 2025-12-21 02:46:50 -05:00

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:
James M. Greene
2021-09-03 13:55:24 -05:00
committed by GitHub
parent 64d43eeeb0
commit fe767f3da0
2 changed files with 97 additions and 46 deletions

View File

@@ -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)
}
}