aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-12-05 13:01:55 +0100
committerGravatar Sebastiaan Zeeff <[email protected]>2020-12-05 13:01:55 +0100
commita2d85eb6b5fc68b687741f23bb5061802f2f88cb (patch)
treed9e4ce398718b6ff9f3677f43d367b0cf9390d9f
parentMitigate session expiry by using fallback session (diff)
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).
-rw-r--r--.github/workflows/build.yaml31
-rw-r--r--.github/workflows/lint.yaml32
2 files changed, 63 insertions, 0 deletions
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/[email protected]
+ 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/[email protected]
+ 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 }}