Skip to content

Update create-jira-issue.yml #6

Update create-jira-issue.yml

Update create-jira-issue.yml #6

name: Create Jira Issue and Sync with GitHub
on:
issues:
types: [opened]
jobs:
create_jira_issue:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create Jira issue
id: create_jira
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
JIRA_PROJECT_KEY: ${{ secrets.JIRA_PROJECT_KEY }}
run: |
ISSUE_TITLE="${{ github.event.issue.title }}"
ISSUE_BODY="${{ github.event.issue.body }}"
RESPONSE=$(curl -D- \
-u "$JIRA_EMAIL:$JIRA_API_TOKEN" \
-X POST \
--data '{
"fields": {
"project": {
"key": "'"$JIRA_PROJECT_KEY"'"
},
"summary": "'"$ISSUE_TITLE"'",
"description": "'"$ISSUE_BODY"'",
"issuetype": {
"name": "Task"
}
}
}' \
-H "Content-Type: application/json" \
"$JIRA_BASE_URL/rest/api/2/issue/")
echo "$RESPONSE"
JIRA_ISSUE_KEY=$(echo "$RESPONSE" | grep -oP '(?<=issue\/key\/)\w+-\d+')
echo "JIRA_ISSUE_KEY=$JIRA_ISSUE_KEY" >> $GITHUB_ENV
- name: Create branch for the issue
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
ISSUE_TITLE=${{ github.event.issue.title }}
BRANCH_NAME="feat/issue-${ISSUE_NUMBER}-${JIRA_ISSUE_KEY}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
- name: Add Jira issue key to commit message
env:
JIRA_ISSUE_KEY: ${{ env.JIRA_ISSUE_KEY }}
run: |
echo "JIRA_ISSUE_KEY=${JIRA_ISSUE_KEY}" >> $GITHUB_ENV
on:

Check failure on line 62 in .github/workflows/create-jira-issue.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/create-jira-issue.yml

Invalid workflow file

You have an error in your yaml syntax on line 62
push:
branches:
- 'feat/*'
jobs:
update_jira:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Update Jira issue with commit info
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
JIRA_ISSUE_KEY: ${{ env.JIRA_ISSUE_KEY }}
run: |
COMMITS=$(jq -r '.commits[] | .message' $GITHUB_EVENT_PATH)
curl -D- \
-u "$JIRA_EMAIL:$JIRA_API_TOKEN" \
-X PUT \
--data '{
"update": {
"comment": [
{
"add": {
"body": "'"Commits related to this issue:\n$COMMITS"'"
}
}
]
}
}' \
-H "Content-Type: application/json" \
"$JIRA_BASE_URL/rest/api/2/issue/$JIRA_ISSUE_KEY"