Skip to content

Commit c40a8d2

Browse files
ci: add Slack notification for maintainer PRs
Add a notify job to the PR checks workflow that posts to Slack when an MCP team member opens a non-draft PR and CI passes. A random reviewer from a configured pool is tagged for review. Requires two repo secrets: - MAINTAINER_MAP: JSON with triggers (team members) and reviewers (notification pool) - SLACK_WEBHOOK_URL: Slack workflow webhook URL
1 parent 1ef124e commit c40a8d2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,43 @@ jobs:
1515
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
1616
with:
1717
jobs: ${{ toJSON(needs) }}
18+
19+
notify:
20+
name: Notify maintainers
21+
runs-on: ubuntu-latest
22+
needs: [all-green]
23+
if: >-
24+
!github.event.pull_request.draft &&
25+
needs.all-green.result == 'success'
26+
permissions: {}
27+
steps:
28+
- name: Notify Slack
29+
env:
30+
MAINTAINER_MAP: ${{ secrets.MAINTAINER_MAP }}
31+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
32+
PR_URL: ${{ github.event.pull_request.html_url }}
33+
PR_NUMBER: ${{ github.event.pull_request.number }}
34+
PR_TITLE: ${{ github.event.pull_request.title }}
35+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
36+
run: |
37+
# Check if PR author is on the team (triggers list)
38+
if ! echo "$MAINTAINER_MAP" | jq -e --arg author "$PR_AUTHOR" '.triggers | index($author)' > /dev/null 2>&1; then
39+
echo "PR author $PR_AUTHOR is not on the team, skipping notification"
40+
exit 0
41+
fi
42+
43+
# Pick a random reviewer
44+
ALL_REVIEWERS=$(echo "$MAINTAINER_MAP" | jq -r '.reviewers | keys[]')
45+
REVIEWERS_ARRAY=($ALL_REVIEWERS)
46+
if [ ${#REVIEWERS_ARRAY[@]} -eq 0 ]; then
47+
echo "No reviewers configured"
48+
exit 0
49+
fi
50+
REVIEWER=${REVIEWERS_ARRAY[$((RANDOM % ${#REVIEWERS_ARRAY[@]}))]}
51+
SLACK_ID=$(echo "$MAINTAINER_MAP" | jq -r --arg user "$REVIEWER" '.reviewers[$user].slack')
52+
53+
# Post to Slack
54+
SLACK_TEXT="${PR_URL} \"${PR_TITLE}\" by ${PR_AUTHOR}"
55+
curl -sf -X POST "$SLACK_WEBHOOK_URL" \
56+
-H 'Content-Type: application/json' \
57+
-d "$(jq -n --arg text "$SLACK_TEXT" --arg user_id "$SLACK_ID" '{text: $text, user_id: $user_id}')" || echo "::warning::Slack notification failed"

0 commit comments

Comments
 (0)