Skip to content

Commit

Permalink
Improve status embed workflow (#124)
Browse files Browse the repository at this point in the history
Removes redundant and incorrect condition, removes use of deprecated ::set-output, and ensures correct information is displayed in the embed
  • Loading branch information
wookie184 authored May 24, 2024
1 parent d1acc6e commit b977cf4
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/status_embed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ concurrency:

jobs:
status_embed:
# We send the embed in the following situations:
# - Always after the `Build & Deploy` workflow, as it runs at the
# end of our workflow sequence regardless of status.
# - Always for the `pull_request` event, as it only
# runs one workflow.
# - Always run for non-success workflows, as they
# terminate the workflow sequence.
if: >-
(github.event.workflow_run.name == 'Build & Deploy' && github.event.workflow_run.conclusion != 'skipped') ||
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

Expand All @@ -42,10 +30,10 @@ jobs:
curl -sSL -H "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)"
echo "pr_author_login=$(jq -r '.user.login // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
echo "pr_number=$(jq -r '.number // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
echo "pr_title=$(jq -r '.title // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -60,7 +48,14 @@ jobs:
webhook_id: '784184528997842985'
webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}

# We need to provide the information of the workflow that
# triggered this workflow instead of this workflow.
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 }}

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 }}
Expand Down

0 comments on commit b977cf4

Please sign in to comment.