From c40a8d26ffece431b9542f9836755a8b2ce7f4a4 Mon Sep 17 00:00:00 2001 From: Felix Weinberger Date: Fri, 27 Feb 2026 12:35:02 +0000 Subject: [PATCH] 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 --- .github/workflows/pull-request-checks.yml | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index 502a3631d..7787d6b1c 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -15,3 +15,43 @@ jobs: - uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 with: jobs: ${{ toJSON(needs) }} + + notify: + name: Notify maintainers + runs-on: ubuntu-latest + needs: [all-green] + if: >- + !github.event.pull_request.draft && + needs.all-green.result == 'success' + permissions: {} + steps: + - name: Notify Slack + env: + MAINTAINER_MAP: ${{ secrets.MAINTAINER_MAP }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + run: | + # Check if PR author is on the team (triggers list) + if ! echo "$MAINTAINER_MAP" | jq -e --arg author "$PR_AUTHOR" '.triggers | index($author)' > /dev/null 2>&1; then + echo "PR author $PR_AUTHOR is not on the team, skipping notification" + exit 0 + fi + + # Pick a random reviewer + ALL_REVIEWERS=$(echo "$MAINTAINER_MAP" | jq -r '.reviewers | keys[]') + REVIEWERS_ARRAY=($ALL_REVIEWERS) + if [ ${#REVIEWERS_ARRAY[@]} -eq 0 ]; then + echo "No reviewers configured" + exit 0 + fi + REVIEWER=${REVIEWERS_ARRAY[$((RANDOM % ${#REVIEWERS_ARRAY[@]}))]} + SLACK_ID=$(echo "$MAINTAINER_MAP" | jq -r --arg user "$REVIEWER" '.reviewers[$user].slack') + + # Post to Slack + SLACK_TEXT="${PR_URL} \"${PR_TITLE}\" by ${PR_AUTHOR}" + curl -sf -X POST "$SLACK_WEBHOOK_URL" \ + -H 'Content-Type: application/json' \ + -d "$(jq -n --arg text "$SLACK_TEXT" --arg user_id "$SLACK_ID" '{text: $text, user_id: $user_id}')" || echo "::warning::Slack notification failed"