From a2d85eb6b5fc68b687741f23bb5061802f2f88cb Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff Date: Sat, 5 Dec 2020 13:01:55 +0100 Subject: Use custom status embeds for workflow runs This commit introduces enhanced status embeds for workflow runs that give more information about run that just ended. An added advantage is that we can disable the default "give me everything"-setting of GitHub and fine tune when we want to send embeds. This allows us to only send an embed for the `lint->build` sequence when the sequence ends (e.g. in the end when done or after an intermediate step due to failure/cancellation). --- .github/workflows/build.yaml | 31 +++++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b0c03139..64c272cf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -75,3 +75,34 @@ jobs: kubernetes/sir-lancebot/deployment.yaml images: 'ghcr.io/python-discord/sir-lancebot:${{ steps.sha_tag.outputs.tag }}' kubectl-version: 'latest' + + # 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 + # This is the last step in the lint-build sequence, so always send + # an embed, regardless of success, failure or cancelled status. + if: always() + uses: SebastiaanZ/github-status-embed-for-discord@v0.1.1 + with: + # Our GitHub Actions webhook + webhook_id: '784184528997842985' + webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} + + # Workflow information + workflow_name: ${{ github.workflow }} + run_id: ${{ github.run_id }} + run_number: ${{ github.run_number }} + status: ${{ job.status }} + actor: ${{ github.actor }} + repository: ${{ github.repository }} + ref: ${{ github.ref }} + sha: ${{ github.sha }} + + # Optional PR-information. These values will be "null" if + # the event trigger was not PR-related. + pr_author_login: ${{ github.event.pull_request.user.login }} + pr_number: ${{ github.event.pull_request.number }} + pr_title: ${{ github.event.pull_request.title }} + pr_source: ${{ github.event.pull_request.head.label }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 063f406c..8dd93773 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -91,3 +91,35 @@ jobs: - name: Run flake8 run: "flake8 \ --format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'" + + # 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 + # For a `pull_request` we always want to send a status embed + # here. For a push event, only when this workflow is the last + # in lint->build sequence because it failed or was cancelled. + if: github.event_name == 'pull_request' || cancelled() || failure() + uses: SebastiaanZ/github-status-embed-for-discord@v0.1.1 + with: + # Our GitHub Actions webhook + webhook_id: '784184528997842985' + webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} + + # Workflow information + workflow_name: ${{ github.workflow }} + run_id: ${{ github.run_id }} + run_number: ${{ github.run_number }} + status: ${{ job.status }} + actor: ${{ github.actor }} + repository: ${{ github.repository }} + ref: ${{ github.ref }} + sha: ${{ github.sha }} + + # Optional PR-information. These values will be "null" if + # the event trigger was not PR-related. + pr_author_login: ${{ github.event.pull_request.user.login }} + pr_number: ${{ github.event.pull_request.number }} + pr_title: ${{ github.event.pull_request.title }} + pr_source: ${{ github.event.pull_request.head.label }} -- cgit v1.2.3