From 95b407e8ad90171c667572c8fec92d62ff0ef28d Mon Sep 17 00:00:00 2001 From: cberg-aot <93226309+cberg-aot@users.noreply.github.com> Date: Tue, 9 Jan 2024 16:40:44 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20refactored=20notifications=20to=20correc?= =?UTF-8?q?tly=20display=20pr=20and=20diff=20on=20but=E2=80=A6=20(#1750)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/notifications.yml | 51 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/notifications.yml b/.github/workflows/notifications.yml index a88850165..116e5c09a 100644 --- a/.github/workflows/notifications.yml +++ b/.github/workflows/notifications.yml @@ -3,49 +3,62 @@ on: workflow_run: workflows: [PR,Merge] types: - - requested - - in_progess - completed jobs: - notify-teams-in-progress: - if: ${{github.event.workflow_run.status != 'completed'}} + notify-teams-pr: + if: ${{github.event.workflow_run.event == 'pull_request'}} runs-on: ubuntu-22.04 steps: - uses: simbo/msteams-message-card-action@latest with: webhook: ${{ vars.MS_TEAMS_WEBHOOK_URI }} - title: "PR# ${{github.event.workflow_run.pull_requests[0].number}}" + title: "${{github.event.workflow_run.head_commit.message}}" message: "${{github.event.workflow_run.head_commit.message}}" - color: ff69b4 + color: 'dodger blue' buttons: | Pull Request ${{github.event.workflow_run.pull_requests[0].number}} ${{github.event.workflow_run.repository.html_url}}/pull/${{github.event.workflow_run.pull_requests[0].number}} Diff ${{github.event.workflow_run.repository.html_url}}/pull/${{github.event.workflow_run.pull_requests[0].number}}/files sections: | - - + - activity: - title: ${{github.event.workflow_run.head_commit.committer.name }} + title: ${{github.event.workflow_run.head_commit.committer.name}} subtitle: ${{github.event.workflow_run.head_commit.timestamp}} image: ${{github.event.workflow_run.head_repository.owner.avatar_url}} - text: | - status: ${{github.event.workflow_run.status}} - notify-teams-completed: - if: ${{github.event.workflow_run.status == 'completed'}} + text: PR Opened + notify-teams-merged: + if: ${{github.event.workflow_run.event == 'push'}} runs-on: ubuntu-22.04 steps: + - name: PR Number + id: pr + shell: bash + run: | + pr=$(\ + curl -sL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls \ + | jq .[0].number + ) + if [ -z "${pr}" ] + then + echo "No PR number found. Was this push triggered by a squashed PR merge?" + pr="" + fi + echo "pr=${pr}" >> $GITHUB_OUTPUT - uses: simbo/msteams-message-card-action@latest with: webhook: ${{ vars.MS_TEAMS_WEBHOOK_URI }} - title: "PR# ${{github.event.workflow_run.pull_requests[0].number}}" + title: "${{github.event.workflow_run.head_commit.message}}" message: "${{github.event.workflow_run.head_commit.message}}" - color: 28a745 + color: 'dark orange' + summary: "${{github.event.workflow_run.event}}-${{github.event.workflow_run.status}}" buttons: | - Pull Request ${{github.event.workflow_run.pull_requests[0].number}} ${{github.event.workflow_run.repository.html_url}}/pull/${{github.event.workflow_run.pull_requests[0].number}} - Diff ${{github.event.workflow_run.repository.html_url}}/pull/${{github.event.workflow_run.pull_requests[0].number}}/files + Pull Request ${{steps.pr.outputs.pr}} ${{github.event.workflow_run.repository.html_url}}/pull/${{steps.pr.outputs.pr}} + Diff ${{github.event.workflow_run.repository.html_url}}/pull/${{steps.pr.outputs.pr}}/files sections: | - - + - activity: title: ${{github.event.workflow_run.head_commit.committer.name}} subtitle: ${{github.event.workflow_run.head_commit.timestamp}} image: ${{github.event.workflow_run.head_repository.owner.avatar_url}} - text: | - status: ${{github.event.workflow_run.status}} + text: Merged