diff options
author | 2020-12-16 13:50:23 +0100 | |
---|---|---|
committer | 2020-12-16 13:50:23 +0100 | |
commit | d9518d03016360ff9a1f3d69b1c7d18034d5f2d0 (patch) | |
tree | 4346d7790bb9c04ac716067ba3903fbbfe4e90fc /.github | |
parent | Merge pull request #34 from python-discord/ks123/form-delete (diff) |
Add enhanced status embed workflow
I've added a `workflow-run`-triggered workflow that sends an enhanced
status embed to our #dev-log GitHub Actions webhook. It will run
whenever the main workflow finishes and report its status.
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/status-embed.yml | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/.github/workflows/status-embed.yml b/.github/workflows/status-embed.yml new file mode 100644 index 0000000..124bdea --- /dev/null +++ b/.github/workflows/status-embed.yml @@ -0,0 +1,56 @@ +name: Status Embed + +on: + workflow_run: + workflows: + - Forms Backend + types: + - completed + +jobs: + status_embed: + if: github.event.workflow_run.conclusion != 'skipped' + name: Send a Status Embed to Discord + runs-on: ubuntu-latest + + steps: + - name: Get Pull Request Information + id: pr_info + if: github.event.workflow_run.event == 'pull_request' + run: | + curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json + DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url') + [ -z "$DOWNLOAD_URL" ] && exit 1 + wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2 + unzip -p pull_request_payload.zip > pull_request_payload.json + [ -s pull_request_payload.json ] || exit 3 + echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)" + echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)" + echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)" + echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Send an informational status embed to Discord instead of the + # standard embeds that Discord sends. This embed will contain + # more information and we can fine tune when we actually want + # to send an embed. + - name: GitHub Actions Status Embed for Discord + uses: SebastiaanZ/[email protected] + with: + # Our GitHub Actions webhook + webhook_id: '784184528997842985' + webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} + + # Workflow information + workflow_name: ${{ github.event.workflow_run.name }} + run_id: ${{ github.event.workflow_run.id }} + run_number: ${{ github.event.workflow_run.run_number }} + status: ${{ github.event.workflow_run.conclusion }} + sha: ${{ github.event.workflow_run.head_sha }} + + # Now we can use the information extracted in the previous step: + pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }} + pr_number: ${{ steps.pr_info.outputs.pr_number }} + pr_title: ${{ steps.pr_info.outputs.pr_title }} + pr_source: ${{ steps.pr_info.outputs.pr_source }} |