85 lines
3.9 KiB
YAML
85 lines
3.9 KiB
YAML
|
on:
|
||
|
issues:
|
||
|
types: [opened, closed, deleted, reopened]
|
||
|
issue_comment:
|
||
|
types: [created]
|
||
|
workflow_dispatch:
|
||
|
|
||
|
name: Jira Community Issue Sync
|
||
|
|
||
|
jobs:
|
||
|
sync:
|
||
|
runs-on: ubuntu-latest
|
||
|
name: Jira Community Issue sync
|
||
|
steps:
|
||
|
- name: Login
|
||
|
uses: atlassian/gajira-login@v3.0.0
|
||
|
env:
|
||
|
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
|
||
|
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
|
||
|
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
|
||
|
|
||
|
- name: Set ticket type
|
||
|
id: set-ticket-type
|
||
|
run: |
|
||
|
echo "TYPE=GH Issue" >> $GITHUB_OUTPUT
|
||
|
|
||
|
- name: Set ticket labels
|
||
|
if: github.event.action == 'opened'
|
||
|
id: set-ticket-labels
|
||
|
run: |
|
||
|
LABELS="["
|
||
|
if [[ "${{ contains(github.event.issue.labels.*.name, 'type/bug') }}" == "true" ]]; then LABELS+="\"type/bug\", "; fi
|
||
|
if [[ "${{ contains(github.event.issue.labels.*.name, 'type/enhancement') }}" == "true" ]]; then LABELS+="\"type/enhancement\", "; fi
|
||
|
if [[ "${{ contains(github.event.issue.labels.*.name, 'type/docs') }}" == "true" ]]; then LABELS+="\"type/docs\", "; fi
|
||
|
if [[ ${#LABELS} != 1 ]]; then LABELS=${LABELS::-2}"]"; else LABELS+="]"; fi
|
||
|
echo "LABELS=${LABELS}" >> $GITHUB_OUTPUT
|
||
|
|
||
|
- name: Create ticket if an issue is filed, or if PR not by a team member is opened
|
||
|
if: github.event.action == 'opened'
|
||
|
uses: tomhjp/gh-action-jira-create@v0.2.0
|
||
|
with:
|
||
|
project: NET
|
||
|
issuetype: "${{ steps.set-ticket-type.outputs.TYPE }}"
|
||
|
summary: "${{ github.event.repository.name }} [${{ steps.set-ticket-type.outputs.TYPE }} #${{ github.event.issue.number }}]: ${{ github.event.issue.title }}"
|
||
|
description: "${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created in GitHub by ${{ github.actor }}._"
|
||
|
# customfield_10089 is "Issue Link", customfield_10371 is "Source" (use JIRA API to retrieve)
|
||
|
extraFields: '{ "customfield_10089": "${{ github.event.issue.html_url || github.event.pull_request.html_url }}",
|
||
|
"customfield_10371": { "value": "GitHub" },
|
||
|
"customfield_10535": [{ "value": "Service Mesh" }],
|
||
|
"components": [{ "name": "${{ github.event.repository.name }}" }],
|
||
|
"labels": ${{ steps.set-ticket-labels.outputs.LABELS }} }'
|
||
|
env:
|
||
|
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
|
||
|
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
|
||
|
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
|
||
|
|
||
|
- name: Search
|
||
|
if: github.event.action != 'opened'
|
||
|
id: search
|
||
|
uses: tomhjp/gh-action-jira-search@v0.2.1
|
||
|
with:
|
||
|
# cf[10089] is Issue Link (use JIRA API to retrieve)
|
||
|
jql: 'issuetype = "${{ steps.set-ticket-type.outputs.TYPE }}" and cf[10089] = "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"'
|
||
|
|
||
|
- name: Sync comment
|
||
|
if: github.event.action == 'created' && steps.search.outputs.issue
|
||
|
uses: tomhjp/gh-action-jira-comment@v0.1.0
|
||
|
with:
|
||
|
issue: ${{ steps.search.outputs.issue }}
|
||
|
comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}"
|
||
|
|
||
|
- name: Close ticket
|
||
|
if: ( github.event.action == 'closed' || github.event.action == 'deleted' ) && steps.search.outputs.issue
|
||
|
uses: atlassian/gajira-transition@v2.0.1
|
||
|
with:
|
||
|
issue: ${{ steps.search.outputs.issue }}
|
||
|
transition: "Closed"
|
||
|
|
||
|
- name: Reopen ticket
|
||
|
if: github.event.action == 'reopened' && steps.search.outputs.issue
|
||
|
uses: atlassian/gajira-transition@v2.0.1
|
||
|
with:
|
||
|
issue: ${{ steps.search.outputs.issue }}
|
||
|
transition: "To Do"
|