This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
testing auto assign #15
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
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: Assign specified users to the issue | |
run: | | |
users=("jgomez720" "PapalapticAfterblast") | |
ISSUE_NUMBER=${{ github.event.issue.number }} # Get issue number from the input | |
echo "Repository: ${{ github.repository }}" | |
echo "Issue Number: ${{ github.event.issue.number }}" | |
# 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") | |
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 |