Status embeds was broken on other branches besides main, now artifacts are always checked

This commit is contained in:
Xithrius 2022-03-24 02:24:58 -07:00
parent e70df63273
commit 55d76989a5
No known key found for this signature in database
GPG Key ID: BD0FC909FA912B62
2 changed files with 47 additions and 5 deletions

View File

@ -57,3 +57,26 @@ jobs:
- name: Check code for possible improvements
run: cargo clippy -- -D warnings
# Prepare the Pull Request Payload artifact. If this fails, we
# we fail silently using the `continue-on-error` option. It's
# nice if this succeeds, but if it fails for any reason, it
# does not mean that our lint-test checks failed.
- name: Prepare Pull Request Payload artifact
id: prepare-artifact
if: always() && github.event_name == 'pull_request'
continue-on-error: true
run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json
# This only makes sense if the previous step succeeded. To
# get the original outcome of the previous step before the
# `continue-on-error` conclusion is applied, we use the
# `.outcome` value. This step also fails silently.
- name: Upload a Build Artifact
if: always() && steps.prepare-artifact.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v2
with:
name: pull-request-payload
path: pull_request_payload.json

View File

@ -7,13 +7,34 @@ on:
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
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 CI workflow,
# as the sequence always terminates with one run.
#
# 3. If any workflow ends in failure or was cancelled.
if: >-
github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'cancelled'
name: Send Status Embed to Discord
runs-on: ubuntu-latest
steps:
# Process the artifact uploaded in the `pull_request`-triggered workflow:
# A workflow_run event does not contain all the information
# we need for a PR embed. That's why we upload an artifact
# with that information in the Lint workflow.
- name: Get Pull Request Information
id: pr_info
if: github.event.workflow_run.event == 'pull_request'
@ -38,12 +59,11 @@ jobs:
- name: GitHub Actions Status Embed for Discord
uses: SebastiaanZ/github-status-embed-for-discord@main
with:
# Webhook token
# Our GitHub Actions webhook
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
# We need to provide the information of the workflow that
# triggered this workflow instead of this workflow.
# Workflow information
workflow_name: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
run_number: ${{ github.event.workflow_run.run_number }}
@ -53,7 +73,6 @@ jobs:
ref: ${{ github.ref }}
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 }}