-
Notifications
You must be signed in to change notification settings - Fork 2
Notify team members via webhook #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
toby-plunkett
wants to merge
6
commits into
master
Choose a base branch
from
Create-send-team-members.yml
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
996aed2
Create send-team-members.yml
toby-plunkett 76cab32
fix race condition
toby-plunkett d5baca3
Update CODEOWNERS
toby-plunkett 7b3dd67
Update README.md
toby-plunkett 557d4f0
Update README.md
toby-plunkett 60d7acf
fix linting
toby-plunkett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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..." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?