Skip to content

Commit

Permalink
fix: Action will not assign user if another user is assigned (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizel Scarlett authored Jan 4, 2022
1 parent 67f0766 commit c77267b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ runs:
ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
ISSUE_CURRENTLY_ASSIGNED=`echo $ISSUE_JSON | jq '.assignees | length == 0'`
if [[ $BODY == *".take"* ]]; then
echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
if [[ ! -z $INPUT_MESSAGE ]]; then
jq -n -r --arg body "$INPUT_MESSAGE" '{body: $body}' > payload.json
curl -X POST -H "Authorization: token $GITHUB_TOKEN" --data @payload.json https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/comments
if [[ "$ISSUE_CURRENTLY_ASSIGNED" == true ]]; then
echo "$ISSUE_CURRENTLY_ASSIGNED"
echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
if [[ ! -z $INPUT_MESSAGE ]]; then
jq -n -r --arg body "$INPUT_MESSAGE" '{body: $body}' > payload.json
curl -X POST -H "Authorization: token $GITHUB_TOKEN" --data @payload.json https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/comments
fi
else
echo "This issue is currently assigned to a different user"
fi
fi
shell: bash
Expand Down

0 comments on commit c77267b

Please sign in to comment.