Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactored notifications to correctly display pr and diff on but… #1750

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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