Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit b80e1ba

Browse files
ci: PLATE-675: Enable jira chatops command for issues (#282)
Co-authored-by: Nikita Belonogov <[email protected]>
1 parent 34d39c2 commit b80e1ba

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/jira-command.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "/git command"
1+
name: "/jira command"
22

33
on:
44
repository_dispatch:

.github/workflows/slash-command-dispatch.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ env:
99
git
1010
jira
1111
12+
issue_commands_list: |
13+
jira
14+
1215
jobs:
1316
slashCommandDispatch:
1417
if: startsWith(github.event.comment.body, '/')
@@ -22,25 +25,42 @@ jobs:
2225
uses: actions/github-script@v7
2326
env:
2427
COMMANDS_LIST: ${{ env.commands_list }}
28+
ISSUE_COMMANDS_LIST: ${{ env.issue_commands_list }}
2529
with:
2630
github-token: ${{ secrets.GIT_PAT }}
2731
script: |
2832
const body = context.payload.comment.body.toLowerCase().trim()
2933
const commands_list = process.env.COMMANDS_LIST.split("\n")
34+
const issue_commands_list = process.env.ISSUE_COMMANDS_LIST.split("\n")
3035
console.log("Detected PR comment: " + body)
3136
console.log("Commands list: " + commands_list)
37+
console.log("Issue commands list: " + issue_commands_list)
3238
commandArray = body.split(/\s+/)
3339
const contextCommand = commandArray[0].split('/')[1].trim();
3440
console.log("contextCommand: " + contextCommand)
3541
core.setOutput('command_state', 'known')
42+
core.setOutput('is_issue_command', 'false')
3643
if (! commands_list.includes(contextCommand)) {
3744
core.setOutput('command_state', 'unknown')
3845
core.setOutput('command', contextCommand)
3946
}
47+
if (issue_commands_list.includes(contextCommand)) {
48+
core.setOutput('is_issue_command', 'true')
49+
}
50+
51+
- name: Slash Command Dispatch for Issues
52+
id: scd_issues
53+
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command == 'true' }}
54+
uses: peter-evans/slash-command-dispatch@v3
55+
with:
56+
token: ${{ secrets.GIT_PAT }}
57+
issue-type: "issue"
58+
reactions: true
59+
commands: ${{ env.issue_commands_list }}
4060

41-
- name: Slash Command Dispatch
42-
id: scd
43-
if: ${{ steps.determine_command.outputs.command_state != 'unknown' }}
61+
- name: Slash Command Dispatch for PRs
62+
id: scd_prs
63+
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command != 'true' }}
4464
uses: peter-evans/slash-command-dispatch@v3
4565
with:
4666
token: ${{ secrets.GIT_PAT }}
@@ -54,6 +74,6 @@ jobs:
5474
with:
5575
comment-id: ${{ github.event.comment.id }}
5676
body: |
57-
> '/${{ steps.determine_command.outputs.command }}' is unknown command.
77+
> '/${{ steps.determine_command.outputs.command }}' is an unknown command.
5878
> See '/help'
5979
reactions: eyes, confused

0 commit comments

Comments
 (0)