Skip to content

Commit 285c843

Browse files
committed
ci: notify Microsoft Teams about pull request activity
Reuse the Teams notification workflows from mrok so the team channel gets a card when a pull request is built, reviewed, or closed/merged. Add notify-pr-closed and notify-pr-reviewed workflows with the bot image asset, and add the diff and "Notify Microsoft Teams" steps to the PR build workflow, skipped for Dependabot. Skip review notifications from CodeRabbit to avoid noise. Requires the TEAMS_WEBHOOK_URL secret.
1 parent 334b2d7 commit 285c843

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

384 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Notify Teams on PR
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
notify-teams:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v7
12+
with:
13+
fetch-depth: 0
14+
- name: Compute added/removed lines for notification
15+
id: diff
16+
run: |
17+
PR_DATA=$(gh pr view "${{ github.event.pull_request.number }}" --json additions,deletions -q '.')
18+
ADDITIONS=$(echo "$PR_DATA" | jq '.additions')
19+
DELETIONS=$(echo "$PR_DATA" | jq '.deletions')
20+
echo "additions=$ADDITIONS" >> $GITHUB_OUTPUT
21+
echo "deletions=$DELETIONS" >> $GITHUB_OUTPUT
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Notify Microsoft Teams
25+
uses: softwareone-platform/notify-pr-teams-action@v4
26+
with:
27+
webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }}
28+
bot_image_url: https://raw.githubusercontent.com/softwareone-platform/mpt-api-python-client/main/.github/workflows/assets/turing_team_pr_bot.png
29+
repo: ${{ github.repository }}
30+
pr_url: ${{ github.event.pull_request.html_url }}
31+
pr_title: ${{ github.event.pull_request.title }}
32+
pr_author: ${{ github.event.pull_request.user.login }}
33+
head_ref: ${{ github.event.pull_request.head.ref }}
34+
base_ref: ${{ github.event.pull_request.base.ref }}
35+
commits: ${{ github.event.pull_request.commits }}
36+
changed_files: ${{ github.event.pull_request.changed_files }}
37+
additions: ${{ steps.diff.outputs.additions }}
38+
deletions: ${{ steps.diff.outputs.deletions }}
39+
pr_number: ${{ github.event.pull_request.number }}
40+
pr_status: ${{ github.event.pull_request.state }}
41+
is_merged: ${{ github.event.pull_request.merged }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PR Review Notification
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted, edited, dismissed]
6+
7+
jobs:
8+
notify-teams:
9+
if: ${{ github.actor != 'coderabbitai[bot]' }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Get Review Comments Count
13+
id: comments
14+
run: |
15+
COMMENTS_COUNT=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
16+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews/${{ github.event.review.id }}/comments" | jq 'length')
17+
echo "count=$COMMENTS_COUNT" >> $GITHUB_OUTPUT
18+
19+
- name: Notify Teams
20+
uses: softwareone-platform/notify-pr-reviews-teams-action@v2
21+
with:
22+
webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }}
23+
bot_image_url: https://raw.githubusercontent.com/softwareone-platform/mpt-api-python-client/main/.github/workflows/assets/turing_team_pr_bot.png
24+
repo: ${{ github.repository }}
25+
pr_number: ${{ github.event.pull_request.number }}
26+
pr_title: ${{ github.event.pull_request.title }}
27+
reviewer: ${{ github.event.review.user.login }}
28+
review_state: ${{ github.event.review.state }}
29+
global_comment: ${{ github.event.review.body || 'No comment provided' }}
30+
comments_count: ${{ steps.comments.outputs.count }}
31+
head_ref: ${{ github.event.pull_request.head.ref }}
32+
base_ref: ${{ github.event.pull_request.base.ref }}
33+
event: ${{ github.event.action }}
34+
pr_url: ${{ github.event.pull_request.html_url }}

‎.github/workflows/pull-request.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,38 @@ jobs:
3636
- name: "Run validation & test"
3737
run: make check-all
3838

39+
- name: "Compute added/removed lines for notification"
40+
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
41+
id: diff
42+
run: |
43+
PR_DATA=$(gh pr view "${{ github.event.pull_request.number }}" --json additions,deletions -q '.')
44+
ADDITIONS=$(echo "$PR_DATA" | jq '.additions')
45+
DELETIONS=$(echo "$PR_DATA" | jq '.deletions')
46+
echo "additions=$ADDITIONS" >> $GITHUB_OUTPUT
47+
echo "deletions=$DELETIONS" >> $GITHUB_OUTPUT
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: "Notify Microsoft Teams"
52+
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
53+
uses: softwareone-platform/notify-pr-teams-action@v4
54+
with:
55+
webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }}
56+
bot_image_url: https://raw.githubusercontent.com/softwareone-platform/mpt-api-python-client/main/.github/workflows/assets/turing_team_pr_bot.png
57+
repo: ${{ github.repository }}
58+
pr_url: ${{ github.event.pull_request.html_url }}
59+
pr_title: ${{ github.event.pull_request.title }}
60+
pr_author: ${{ github.event.pull_request.user.login }}
61+
head_ref: ${{ github.event.pull_request.head.ref }}
62+
base_ref: ${{ github.event.pull_request.base.ref }}
63+
commits: ${{ github.event.pull_request.commits }}
64+
changed_files: ${{ github.event.pull_request.changed_files }}
65+
additions: ${{ steps.diff.outputs.additions }}
66+
deletions: ${{ steps.diff.outputs.deletions }}
67+
pr_number: ${{ github.event.pull_request.number }}
68+
pr_status: ${{ github.event.pull_request.state }}
69+
is_merged: ${{ github.event.pull_request.merged }}
70+
3971
- name: "Run SonarCloud Scan"
4072
uses: SonarSource/sonarqube-scan-action@v8.2.1
4173
env:

0 commit comments

Comments
 (0)