Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* @hmcts/possession-claim-service-admins
* @hmcts/possession-claim-service-admins @hmcts/possession-claim-frontend

src/test/ui @hmcts/possession-claim-service-qa-admins @hmcts/possession-claim-service-admins

63 changes: 63 additions & 0 deletions .github/workflows/send-team-members.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: send-team-members.yml
on:
pull_request:
types: [opened, ready_for_review]
jobs:
send_reviewers:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was previously mentioned, but could you perhaps check the status of the build beforehand?

steps:
- name: Send assigned reviewers to webhook
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Waiting for reviewer assignment..."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering as the code below is quite lengthy, perhaps could split up into a separate script that can be called here

sleep 10

echo "Fetching reviewers from GitHub API..."
REVIEWERS_JSON=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers")

echo "Fetching GitHub-Slack user mappings..."
MAPPINGS=$(curl -s https://raw.githubusercontent.com/hmcts/github-slack-user-mappings/master/slack.json)

echo "$MAPPINGS" | jq -e '.users' > /dev/null || { echo "Failed to parse users array"; exit 1; }

GITHUB_REVIEWERS=$(echo "$REVIEWERS_JSON" | jq -r '.users[].login')

echo "GitHub reviewers: $GITHUB_REVIEWERS"

SLACK_IDS=""
for github_user in $GITHUB_REVIEWERS; do
echo "Looking up: $github_user"
slack_id=$(echo "$MAPPINGS" | jq -r --arg user "$github_user" '.users[] | select(.github == $user) | .slack')
if [ -n "$slack_id" ]; then
SLACK_IDS="$SLACK_IDS<@$slack_id> "
echo "✓ Mapped $github_user -> $slack_id"
else
SLACK_IDS="$SLACK_IDS@$github_user "
echo "✗ No mapping for $github_user"
fi
done

TEAM_REVIEWERS=$(echo "$REVIEWERS_JSON" | jq -r '.teams[].name' | paste -sd "," -)

PAYLOAD=$(jq -n \
--arg title "$PR_TITLE" \
--arg author "$PR_AUTHOR" \
--arg reviewers "$SLACK_IDS" \
--arg teams "$TEAM_REVIEWERS" \
--arg url "$PR_URL" \
'{"text": ("New PR review requested: \($title) by @\($author) - Reviewers: \($reviewers)\(if $teams != "" then " Team: \($teams)" else "" end) - \($url)")}')

curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"

echo "Sent to webhook successfully!"
Loading