From b15422f6c8dec44d3a47f7c5c986083ee726fc7c Mon Sep 17 00:00:00 2001 From: Nikita Belonogov Date: Sun, 10 Dec 2023 11:34:02 +0400 Subject: [PATCH] ci: PLATE-675: Enable jira chatops command for issues --- .github/workflows/jira-command.yml | 2 +- .github/workflows/slash-command-dispatch.yml | 28 +++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jira-command.yml b/.github/workflows/jira-command.yml index bde6b9c8..76ad92ca 100644 --- a/.github/workflows/jira-command.yml +++ b/.github/workflows/jira-command.yml @@ -1,4 +1,4 @@ -name: "/git command" +name: "/jira command" on: repository_dispatch: diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml index 7aa1f0f9..93c873b4 100644 --- a/.github/workflows/slash-command-dispatch.yml +++ b/.github/workflows/slash-command-dispatch.yml @@ -7,6 +7,9 @@ env: commands_list: | jira + issue_commands_list: | + jira + jobs: slashCommandDispatch: if: startsWith(github.event.comment.body, '/') @@ -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 }} @@ -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