Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
ci: PLATE-675: Enable jira chatops command for issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabelonogov committed Dec 10, 2023
1 parent 94badcd commit b15422f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jira-command.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "/git command"
name: "/jira command"

on:
repository_dispatch:
Expand Down
28 changes: 24 additions & 4 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ env:
commands_list: |
jira
issue_commands_list: |
jira
jobs:
slashCommandDispatch:
if: startsWith(github.event.comment.body, '/')
Expand All @@ -20,25 +23,42 @@ jobs:
uses: actions/github-script@v7
env:
COMMANDS_LIST: ${{ env.commands_list }}
ISSUE_COMMANDS_LIST: ${{ env.issue_commands_list }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const body = context.payload.comment.body.toLowerCase().trim()
const commands_list = process.env.COMMANDS_LIST.split("\n")
const issue_commands_list = process.env.ISSUE_COMMANDS_LIST.split("\n")
console.log("Detected PR comment: " + body)
console.log("Commands list: " + commands_list)
console.log("Issue commands list: " + issue_commands_list)
commandArray = body.split(/\s+/)
const contextCommand = commandArray[0].split('/')[1].trim();
console.log("contextCommand: " + contextCommand)
core.setOutput('command_state', 'known')
core.setOutput('is_issue_command', 'false')
if (! commands_list.includes(contextCommand)) {
core.setOutput('command_state', 'unknown')
core.setOutput('command', contextCommand)
}
if (issue_commands_list.includes(contextCommand)) {
core.setOutput('is_issue_command', 'true')
}
- name: Slash Command Dispatch for Issues
id: scd_issues
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command == 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
issue-type: "issue"
reactions: true
commands: ${{ env.issue_commands_list }}

- name: Slash Command Dispatch
id: scd
if: ${{ steps.determine_command.outputs.command_state != 'unknown' }}
- name: Slash Command Dispatch for PRs
id: scd_prs
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command != 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
Expand All @@ -52,6 +72,6 @@ jobs:
with:
comment-id: ${{ github.event.comment.id }}
body: |
> '/${{ steps.determine_command.outputs.command }}' is unknown command.
> '/${{ steps.determine_command.outputs.command }}' is an unknown command.
> See '/help'
reactions: eyes, confused

0 comments on commit b15422f

Please sign in to comment.