This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update workflow * update worklfow * debug * update with error handling * add test issue number * write access * update workflow * 😒 * 😒😒 * hmmmm * clean up
- Loading branch information
Showing
1 changed file
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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,37 +1,36 @@ | ||
name: Auto Assign Team to Issues | ||
name: Auto Assign Users | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
issues: write # Required to assign users to the issue | ||
|
||
jobs: | ||
auto-assign-team: | ||
runs-on: ubuntu-latest | ||
|
||
|
||
steps: | ||
- name: Get team members using GitHub API | ||
id: team-members | ||
- name: Assign specified users to the issue | ||
run: | | ||
response=$(curl -L \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/orgs/KittyCAD/teams/support/members) | ||
echo "API Response:" | ||
echo "$response" | jq '.' # Debug to see the structure | ||
users=("jgomez720" "PapalapticAfterblast") | ||
ISSUE_NUMBER=${{ github.event.inputs.issue_number }} # Get issue number from the input | ||
# Extract the member logins | ||
echo "$response" | jq -r '.[].login' > team_members.txt | ||
# Create a properly formatted JSON string for the assignees array | ||
assignees_json=$(printf '%s\n' "${users[@]}" | jq -R . | jq -s .) | ||
echo "Assigning users: $assignees_json" | ||
# Assign users to the issue using the correct endpoint | ||
response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-d "{\"assignees\": $assignees_json}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/assignees") | ||
- name: Assign team members to the issue | ||
run: | | ||
while IFS= read -r member; do | ||
curl -s -X POST \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-d "{\"assignees\": [\"$member\"]}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}" | ||
done < team_members.txt | ||
if [ "$response" -eq 201 ]; then | ||
echo "Successfully assigned users to issue #$ISSUE_NUMBER." | ||
else | ||
echo "Error: Failed to assign users. HTTP response code: $response" | ||
fi |