github.com/hashicorp/packer@v1.14.3/.github/workflows/jira.yml (about)

     1  on:
     2    issues:
     3      types: [labeled]
     4  
     5  permissions:
     6    contents: read
     7  
     8  name: JIRA Sync
     9  
    10  jobs:
    11    sync:
    12      name: Sync to JIRA
    13      permissions:
    14        issues: write # for actions/github-script to create comments
    15      runs-on: ubuntu-latest
    16      steps:    
    17        - name: Login
    18          uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1
    19          env:
    20            JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
    21            JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
    22            JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
    23  
    24        - name: Search
    25          if: github.event.action == 'labeled'
    26          id: search
    27          uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2
    28          with:
    29            # cf[10089] is Issue Link (use JIRA API to retrieve)
    30            jql: 'project = "HPR" AND cf[10089] = "${{ github.event.issue.html_url }}"'
    31  
    32  
    33        - name: Set type
    34          id: set-ticket-type
    35          run: |
    36            # Questions are not tracked in JIRA at this time.
    37            if [[ "${{ contains(github.event.issue.labels.*.name, 'question') }}" == "true" ]]; then
    38              echo "type=Invalid" >> $GITHUB_OUTPUT
    39            else
    40              # Properly labeled GH issues are assigned the standard "GH Issue" type upon creation.
    41              echo "type=GH Issue" >> $GITHUB_OUTPUT
    42            fi
    43  
    44        - name: Set labels
    45          id: set-ticket-labels 
    46          run: |
    47            if [[ "${{ contains(github.event.issue.labels.*.name, 'bug') }}" == "true" ]]; then
    48              echo "labels=[\"bug\"]" >> $GITHUB_OUTPUT
    49            elif [[ "${{ contains(github.event.issue.labels.*.name, 'enhancement') }}" == "true" ]]; then
    50              echo "labels=[\"enhancement\"]" >> $GITHUB_OUTPUT
    51            else
    52              echo "labels=[]" >> $GITHUB_OUTPUT
    53            fi
    54  
    55        - name: Validate ticket
    56          if: steps.set-ticket-type.outputs.type == 'Invalid'
    57          run: |
    58            echo "Questions are not being synced to JIRA at this time."
    59            echo "If the issue is a bug or an enhancement please remove the question label and reapply the 'sync to jira' label."
    60  
    61        - name: Create ticket
    62          id: create-ticket
    63          if: steps.search.outputs.issue == '' && github.event.label.name == 'sync to jira' && steps.set-ticket-type.outputs.type != 'Invalid'
    64          uses: atlassian/gajira-create@59e177c4f6451399df5b4911c2211104f171e669 # v3.0.1
    65          with:
    66            project: HPR
    67            issuetype: "${{ steps.set-ticket-type.outputs.type }}"
    68            summary: "${{ github.event.repository.name }}: ${{ github.event.issue.title }}"
    69            description: "${{ github.event.issue.body }}\n\n_Created from GitHub by ${{ github.actor }}._"
    70            # The field customfield_10089 refers to the Issue Link field in JIRA. 
    71            fields: '{ "customfield_10089": "${{ github.event.issue.html_url }}", "components": [{ "name": "core" }], "labels": ${{ steps.set-ticket-labels.outputs.labels }} }'
    72  
    73        - name: Add tracking comment
    74          if: steps.create-ticket.outputs.issue != '' && steps.set-ticket-type.outputs.type != 'Invalid'
    75          uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
    76          with:
    77            script: |
    78              github.rest.issues.createComment({
    79                issue_number: context.issue.number,
    80                owner: context.repo.owner,
    81                repo: context.repo.repo,
    82                body: `
    83                  This issue has been synced to JIRA for planning.
    84                  JIRA ID: [${{ steps.create-ticket.outputs.issue }}](https://hashicorp.atlassian.net/browse/${{steps.create-ticket.outputs.issue}})`
    85              })
    86