One month ago I wrote a Github Actions Workflow that 1. Finds any JIRA issue numbers in a merged pull request, and 2. Uses the JIRA rest API to move those tickets into a target repo/environment (in this case it is Staging and Production).
Here is the API call portion of my script:
```
- name: Send HTTP Request
run: |
str="${{ github.event.pull_request.body }} ${{ github.event.pull_request.title}} ${{ steps.get_head_commit_message.outputs.head-commit-message }}"
echo $str
jira_ids=$(echo "$str" | grep -o "[A-Z]*-[0-9]*")
echo $jira_ids
# Convert string of JIRA ids to array
jira_ids_arr=($jira_ids)
staging_deployed="2"
production_deployed="31"
if [[ ${{ github.ref }} == "staging" ]]
then
env=$staging_deployed
elif [[ ${{ github.ref }} == "main" ]]
then
env=$production_deployed
else
env="1"
fi
# Print each JIRA id
for id in "${jira_ids_arr[@]}"; do curl \
-u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} \
-X POST \
--data '{"transition":{"id":'$env'}}' \
-H "Content-Type: application/json" \
${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/$id/transitions
done
```
It worked for a week or two, and then seemingly out of nowhere I was presented with the following error:
```
{"errorMessages":["Can't move (SCRUM-27). You might not have permission, or the issue is missing required information. If you keep having this problem, contact your Jira Administrator."],"errors":{}}
```
I've tried:
1. Checking that the target transition ids are correct
2. Updating the API key several times
3. Confirming that my email (Org Admin) and all other keys/secrets are correct and properly stored/declared in github's secrets manager
During the time between when it worked and it started failing, the only change to my JIRA organization (which uses the Free tier) was that I added two new users.
Any help would be greatly appreciated, as it took me a while to get the script working in the first place.