|
| 1 | +name: Create Jira issue |
| 2 | +on: |
| 3 | + issues: |
| 4 | + types: |
| 5 | + - opened |
| 6 | +jobs: |
| 7 | + create-issue: |
| 8 | + name: Create Jira issue |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Login |
| 12 | + uses: atlassian/gajira-login@v3 |
| 13 | + env: |
| 14 | + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} |
| 15 | + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} |
| 16 | + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} |
| 17 | + |
| 18 | + - name: Checkout main code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: main |
| 22 | + |
| 23 | + - name: Issue Parser |
| 24 | + uses: stefanbuck/github-issue-parser@v3 |
| 25 | + id: issue-parser |
| 26 | + with: |
| 27 | + template-path: .github/ISSUE_TEMPLATE/01-feat-template.yml |
| 28 | + |
| 29 | + - name: Log Issue Parser |
| 30 | + run: | |
| 31 | + echo '${{ steps.issue-parser.outputs.jsonString }}' |
| 32 | +
|
| 33 | + - name: Convert markdown to Jira Syntax |
| 34 | + uses: peter-evans/jira2md@v1 |
| 35 | + id: md2jira |
| 36 | + with: |
| 37 | + input-text: | |
| 38 | + ### Github Issue Link |
| 39 | + - ${{ github.event.issue.html_url }} |
| 40 | +
|
| 41 | + ${{ github.event.issue.body }} |
| 42 | + mode: md2jira |
| 43 | + |
| 44 | + - name: Create Issue |
| 45 | + id: create |
| 46 | + uses: atlassian/gajira-create@v3 |
| 47 | + with: |
| 48 | + project: PRODUCT |
| 49 | + issuetype: Task |
| 50 | + summary: "${{ github.event.issue.title }}" |
| 51 | + description: "${{ steps.md2jira.outputs.output-text }}" |
| 52 | + fields: | |
| 53 | + { |
| 54 | + "parent": { |
| 55 | + "key": "${{ steps.issue-parser.outputs.issueparser_parentKey }}" |
| 56 | + } |
| 57 | + } |
| 58 | +
|
| 59 | + - name: Log created issue |
| 60 | + run: echo "Jira Issue ${{ steps.issue-parser.outputs.parentKey }}/${{ steps.create.outputs.issue }} was created" |
| 61 | + |
| 62 | + - name: Get first label as branch prefix |
| 63 | + id: label |
| 64 | + run: | |
| 65 | + PREFIX=$(echo '${{ toJson(github.event.issue.labels) }}' | jq -r '.[0].name // "feat"') |
| 66 | + echo "prefix=$PREFIX" >> $GITHUB_OUTPUT |
| 67 | +
|
| 68 | + - name: Create branch with Ticket number |
| 69 | + run: | |
| 70 | + BRANCH_PREFIX="${{ steps.label.outputs.prefix }}" |
| 71 | + ISSUE_NUMBER="${{ steps.create.outputs.issue }}" |
| 72 | + BRANCH_NAME="${BRANCH_PREFIX}/${ISSUE_NUMBER}" |
| 73 | + git checkout -b "${BRANCH_NAME}" |
| 74 | + git push origin "${BRANCH_NAME}" |
| 75 | +
|
| 76 | + - name: Update issue title |
| 77 | + uses: actions-cool/issues-helper@v3 |
| 78 | + with: |
| 79 | + actions: "update-issue" |
| 80 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + title: "[${{ steps.create.outputs.issue }}] ${{ github.event.issue.title }}" |
0 commit comments