Files
nomad/.github/workflows/jira-sync.yml
Chris Roberts 10be73c081 ci: fix github to jira issue sync (#26747)
Add local actions for JIRA interactions to replace github actions
that have been archived.
2025-09-12 13:40:11 -07:00

67 lines
3.0 KiB
YAML

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
on:
issues:
types: [labeled, opened, closed, deleted, reopened]
issue_comment:
types: [created]
workflow_dispatch:
name: Jira Issue Sync
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
jobs:
sync:
runs-on: ubuntu-latest
name: Jira Issue sync
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Search
if: github.event.action != 'opened'
id: search
uses: ./.github/actions/jira/search
with:
# cf[10089] is Issue Link (use JIRA API to retrieve)
jql: 'cf[10089] = "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"'
- name: Create ticket if an issue is labeled with hcc/jira
if: github.event.action == 'labeled' && github.event.label.name == 'hcc/jira' && !steps.search.outputs.issue
uses: ./.github/actions/jira/create
with:
project: NMD
issuetype: "GH Issue"
summary: "${{ github.event.repository.name }} [GH Issue #${{ 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)
# customerfield_10091 is "Team (R&D)
# customfield_10001 is Team (jira default teams?)
extraFields: '{ "customfield_10089": "${{ github.event.issue.html_url || github.event.pull_request.html_url }}",
"customfield_10001": "72e166fb-d26c-4a61-b0de-7a290d91708f",
"customfield_10371": { "value": "GitHub" },
"customfield_10091": ["NomadMinor"],
"components": [{ "name": "nomad" }],
"labels": ["community", "GitHub"] }'
- name: Sync comment
if: github.event.action == 'created' && steps.search.outputs.issue
uses: ./.github/actions/jira/sync-comment
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: ./.github/actions/jira/transition
with:
issue: ${{ steps.search.outputs.issue }}
transition: "Closed"
- name: Reopen ticket
if: github.event.action == 'reopened' && steps.search.outputs.issue
uses: ./.github/actions/jira/transition
with:
issue: ${{ steps.search.outputs.issue }}
transition: "To Do"