1
0
mirror of synced 2025-12-30 03:01:36 -05:00

add check suite for deploy workflow (#21210)

Co-authored-by: James M. Greene <JamesMGreene@github.com>
This commit is contained in:
Rachael Sewell
2021-08-31 16:02:32 -07:00
committed by GitHub
parent d5e33a8f66
commit 3fc0fa7012

View File

@@ -34,12 +34,32 @@ jobs:
cancel-in-progress: true
outputs:
source_blob_url: ${{ steps.build-source.outputs.download_url }}
check_run_id: ${{ steps.create-check-run.outputs.check_run_id }}
check_run_name: ${{ steps.create-check-run.outputs.check_run_name }}
steps:
- name: Dump event context
env:
GITHUB_EVENT_CONTEXT: ${{ toJSON(github.event) }}
run: echo "$GITHUB_EVENT_CONTEXT"
- name: Create check run
id: create-check-run
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
with:
script: |
// Create a check run
const CHECK_NAME = '${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})'
const { data } = await github.checks.create({
name: CHECK_NAME,
head_sha: '${{github.sha}}',
owner: 'github',
repo: 'docs-internal',
status: 'in_progress',
started_at: new Date()
})
core.setOutput('check_run_id', data.id)
core.setOutput('check_run_name', CHECK_NAME)
- name: Download build artifact
uses: dawidd6/action-download-artifact@b9571484721e8187f1fd08147b497129f8972c74
with:
@@ -177,6 +197,8 @@ jobs:
HYDRO_SECRET: ${{ secrets.HYDRO_SECRET }}
PR_URL: ${{ env.PR_URL }}
SOURCE_BLOB_URL: ${{ needs.prepare.outputs.source_blob_url }}
CHECK_RUN_ID: ${{ needs.prepare.outputs.check_run_id }}
CHECK_RUN_NAME: ${{ needs.prepare.outputs.check_run_name }}
with:
script: |
const { GITHUB_TOKEN, HEROKU_API_TOKEN } = process.env
@@ -205,7 +227,7 @@ jobs:
const octokit = getOctokit()
try {
const { PR_URL, SOURCE_BLOB_URL } = process.env
const { PR_URL, SOURCE_BLOB_URL, CHECK_RUN_ID, CHECK_RUN_NAME } = process.env
const { owner, repo, pullNumber } = parsePrUrl(PR_URL)
if (!owner || !repo || !pullNumber) {
throw new Error(`'pullRequestUrl' input must match URL format 'https://github.com/github/(docs|docs-internal)/pull/123' but was '${PR_URL}'`)
@@ -225,7 +247,36 @@ jobs:
sourceBlobUrl: SOURCE_BLOB_URL,
runId: context.runId
})
await octokit.checks.update({
owner: 'github',
repo: 'docs-internal',
conclusion: 'success',
status: 'completed',
name: CHECK_RUN_NAME,
check_run_id: CHECK_RUN_ID,
output: {
title: 'Successfully deployed to staging',
summary: 'Success',
text: 'Succeeded! 🚀\n\nSee full logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
},
completed_at: new Date()
})
} catch (error) {
await octokit.checks.update({
owner: 'github',
repo: 'docs-internal',
conclusion: 'failure',
status: 'completed',
name: CHECK_RUN_NAME,
check_run_id: CHECK_RUN_ID,
output: {
title: `Failed to deploy to staging: ${error.message}`,
summary: error.message,
text: 'Failed! 🚫\n\nSee full logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
}
completed_at: new Date()
})
console.error(`Failed to deploy to staging: ${error.message}`)
console.error(error)
throw error