Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/jira-issue-transfer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2023 Specter Ops, Inc.
#
# Licensed under the Apache License, Version 2.0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Jira Issue Transfer

on:
issues:
types:
- labeled
jobs:
build:
runs-on: self-hosted
if: github.event.label.name == 'ticketed'
steps:
- name: Login
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Jira Create Bug
id: bug
if: contains(github.event.issue.labels.*.name, 'bug')
uses: atlassian/gajira-create@v3
with:
project: BP
issuetype: 'Bug Report'
summary: ${{ github.event.issue.title }}
description: "Github Issue Link: ${{ github.event.issue.html_url}} \r\n ${{ github.event.issue.body }}"
fields: '{"labels":["GitHubReport"]}'

- name: Jira Create Enhancement
id: enhancement
if: contains(github.event.issue.labels.*.name, 'enhancement')
uses: atlassian/gajira-create@v3
with:
project: BP
issuetype: 'Product Feature'
summary: ${{ github.event.issue.title }}
description: "Github Issue Link: ${{ github.event.issue.html_url}} \r\n ${{ github.event.issue.body }}"
fields: '{"labels":["GitHubReport"]}'
Comment on lines +34 to +54
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential duplicate Jira issues when both bug and enhancement labels are present.

If a GitHub issue has both labels, both the "Jira Create Bug" and "Jira Create Enhancement" steps will execute, creating two separate Jira issues. If this is unintended, consider making the conditions mutually exclusive:

         - name: Jira Create Bug
           id: bug
           if: contains(github.event.issue.labels.*.name, 'bug') 
           uses: atlassian/gajira-create@v3
           ...

         - name: Jira Create Enhancement
           id: enhancement
-          if: contains(github.event.issue.labels.*.name, 'enhancement')
+          if: contains(github.event.issue.labels.*.name, 'enhancement') && !contains(github.event.issue.labels.*.name, 'bug')
           uses: atlassian/gajira-create@v3 

Alternatively, if creating both is intentional, a brief comment documenting this behavior would be helpful.

🤖 Prompt for AI Agents
In @.github/workflows/jira-issue-transfer.yml around lines 34 - 54, The two
workflow steps "Jira Create Bug" (id: bug) and "Jira Create Enhancement" (id:
enhancement) can both run when an issue has both labels; update the step
conditions to make them mutually exclusive (e.g., change the bug step's if to
check for 'bug' and NOT 'enhancement', and change the enhancement step's if to
check for 'enhancement' and NOT 'bug'), or alternatively add a comment above the
steps documenting that creating both Jira issues is intentional; edit the if
expressions on the steps (referencing ids bug and enhancement) to implement the
chosen behavior.

Loading