Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
update workflow (#31)
Browse files Browse the repository at this point in the history
* update workflow

* update worklfow

* debug

* update with error handling

* add test issue number

* write access

* update workflow

* 😒

* 😒😒

* hmmmm

* clean up
  • Loading branch information
jgomez720 authored Sep 13, 2024
1 parent d5b398c commit f67194b
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/assign-issue.yml
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

0 comments on commit f67194b

Please sign in to comment.