From d85f627b80fa0c9f2416fcdad192cc84d510a257 Mon Sep 17 00:00:00 2001 From: wookie184 Date: Sun, 19 May 2024 23:57:25 +0100 Subject: [PATCH] Update status embed workflow Use updated status embed workflow with various fixes and updates. This improves consistency with other repos --- .github/workflows/status-embed.yml | 38 ++++++++++-------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/status-embed.yml b/.github/workflows/status-embed.yml index afabfe36..398564a7 100644 --- a/.github/workflows/status-embed.yml +++ b/.github/workflows/status-embed.yml @@ -7,24 +7,12 @@ 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 Event Validation 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.event.workflow_run.name == 'Event Validation' && 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 @@ -39,13 +27,13 @@ jobs: curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url') [ -z "$DOWNLOAD_URL" ] && exit 1 - wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2 + 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 }} @@ -54,20 +42,18 @@ jobs: # 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.2.1 + uses: SebastiaanZ/github-status-embed-for-discord@v0.3.0 with: # Our GitHub Actions webhook webhook_id: '784184528997842985' webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} - # Workflow information + # 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 }} - actor: ${{ github.actor }} - repository: ${{ github.repository }} - ref: ${{ github.ref }} sha: ${{ github.event.workflow_run.head_sha }} pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}