Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/status_embed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Status Embed

on:
workflow_call:
inputs:
job_status:
required: true
type: string
secrets:
webhook_token:
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true

jobs:
status_embed:
# We need to send a status embed whenever the workflow
# sequence we're running terminates. There are a number
# of situations in which that happens:
#
# 1. We reach the end of the Deploy workflow, without
# it being skipped.
#
# 2. A `pull_request` triggered a Lint & Test workflow,
# as the sequence always terminates with one run.
#
# 3. If any workflow ends in failure or was cancelled.
if: >-
(github.workflow == 'Deploy' && ${{ inputs.job_status }} != 'skipped') ||
Copy link
Copy Markdown
Member

@ChrisLovering ChrisLovering Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Deploy name here won't be the same on all repos. We should make this an input, or standardise the name across our repos as part of the work to use this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we go for the standardization option?

github.event_name == 'pull_request' ||
${{ inputs.job_status }} == 'failure' ||
${{ inputs.job_status }} == 'cancelled'
name: Send Status Embed to Discord
runs-on: ubuntu-latest

steps:
# 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/github-status-embed-for-discord@v0.3.0
with:
# Our GitHub Actions webhook
webhook_id: '784184528997842985'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an input, so the caller can determine what channel it gets sent to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting it as a variable is better, that way we'd avoid having the with statements scattered all over the over workflows that'll call this one.

At worst, we can have it as an input, and default to the variable. But shouldn't be needed in our case

webhook_token: ${{ secrets.webhook_token }}

# Workflow information
status: ${{ inputs.job_status }}
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 }}