11name : Send Team Members to Webhook
22
33on :
4- pull_request :
5- types : [labeled]
4+ pull_request :
5+ types : [labeled]
66
77jobs :
88 send_team_members :
@@ -15,23 +15,34 @@ jobs:
1515 - name : Fetch team members and send to webhook
1616 run : |
1717 # Configuration
18- TEAM_SLUG="possession-claim-backend" # Replace with your team slug
19- ORG_NAME="hmcts" # Replace with your organization name
18+ TEAM_SLUG="possession-claim-backend"
19+ ORG_NAME="hmcts"
2020 WEBHOOK_URL="${{ secrets.WEBHOOK_URL }}"
21+
22+ # Fetch team members - let's see the raw response
23+ echo "Fetching members from: https://api.github.com/orgs/$ORG_NAME/teams/$TEAM_SLUG/members"
2124
22- # Fetch team members from GitHub API
23- MEMBERS=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
25+ RESPONSE=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
2426 "https://api.github.com/orgs/$ORG_NAME/teams/$TEAM_SLUG/members")
2527
26- # Extract just the usernames
27- USERNAMES=$(echo "$MEMBERS" | jq -r '.[].login' | paste -sd "," -)
28+ # Debug: print the raw response
29+ echo "Raw API Response:"
30+ echo "$RESPONSE"
2831
29- # Format for webhook (adjust based on your needs)
30- PAYLOAD=$(jq -n --arg users "$USERNAMES" '{"text": "texttext"}')
32+ # Check if it's valid JSON and an array
33+ if echo "$RESPONSE" | jq -e 'type == "array"' > /dev/null 2>&1; then
34+ echo "Response is a valid array"
35+ USERNAMES=$(echo "$RESPONSE" | jq -r '.[].login' | paste -sd "," -)
36+ echo "Found users: $USERNAMES"
37+ else
38+ echo "ERROR: Response is not an array. Likely an API error:"
39+ echo "$RESPONSE" | jq '.'
40+ exit 1
41+ fi
3142
32- # Send to webhook
43+ # Send to webhook (hardcoded for testing)
3344 curl -X POST "$WEBHOOK_URL" \
3445 -H "Content-Type: application/json" \
35- -d "$PAYLOAD"
46+ -d '{"text": "test message"}'
3647
37- echo "Sent team members to webhook successfully!"
48+ echo "Sent to webhook successfully!"
0 commit comments