Skip to content

Commit

Permalink
fix: refactored notifications to correctly display pr and diff on but… (
Browse files Browse the repository at this point in the history
  • Loading branch information
cberg-aot committed Jan 10, 2024
1 parent 9dfe703 commit 95b407e
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions .github/workflows/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 95b407e

Please sign in to comment.