@@ -13,25 +13,37 @@ jobs:
1313 run : |
1414 WEBHOOK_URL="${{ secrets.WEBHOOK_URL }}"
1515
16- # Get individual reviewers
17- REVIEWERS=$(echo '${{ toJson(github.event.pull_request.requested_reviewers) }}' | jq -r '.[].login' | paste -sd "," -)
16+ echo "Fetching GitHub-Slack user mappings..."
17+ MAPPINGS=$(curl -s https://raw.githubusercontent.com/hmcts/github-slack-user-mappings/master/slack.json)
18+
19+ echo "Mappings fetched:"
20+ echo "$MAPPINGS" | jq '.'
21+
22+ GITHUB_REVIEWERS=$(echo '${{ toJson(github.event.pull_request.requested_reviewers) }}' | jq -r '.[].login')
23+
24+ SLACK_IDS=""
25+ for github_user in $GITHUB_REVIEWERS; do
26+ slack_id=$(echo "$MAPPINGS" | jq -r --arg user "$github_user" '.[$user] // empty')
27+ if [ -n "$slack_id" ]; then
28+ SLACK_IDS="$SLACK_IDS<@$slack_id> "
29+ echo "Mapped $github_user -> $slack_id"
30+ else
31+ SLACK_IDS="$SLACK_IDS@$github_user "
32+ echo "No mapping found for $github_user, using GitHub username"
33+ fi
34+ done
1835
19- # Get team reviewers (if teams were assigned)
2036 TEAM_REVIEWERS=$(echo '${{ toJson(github.event.pull_request.requested_teams) }}' | jq -r '.[].name' | paste -sd "," -)
2137
22- # Combine both
23- ALL_REVIEWERS="${REVIEWERS}${TEAM_REVIEWERS:+,}${TEAM_REVIEWERS}"
24-
25- echo "Assigned reviewers: $ALL_REVIEWERS"
26-
27- # Build the message
2838 PR_TITLE="${{ github.event.pull_request.title }}"
2939 PR_URL="${{ github.event.pull_request.html_url }}"
3040 PR_AUTHOR="${{ github.event.pull_request.user.login }}"
3141
32- MESSAGE="New PR review requested: '$PR_TITLE' by @$PR_AUTHOR - Reviewers: $ALL_REVIEWERS - $PR_URL"
42+ MESSAGE="New PR review requested: '$PR_TITLE' by @$PR_AUTHOR\nReviewers: $SLACK_IDS${TEAM_REVIEWERS:+Team: $TEAM_REVIEWERS}\n$PR_URL"
43+
44+ echo "Final message:"
45+ echo "$MESSAGE"
3346
34- # Send to webhook
3547 PAYLOAD=$(jq -n --arg text "$MESSAGE" '{"text": $text}')
3648
3749 curl -X POST "$WEBHOOK_URL" \
0 commit comments