From 0c36256e93b651ac0fe818254ed67efb1bd15ae8 Mon Sep 17 00:00:00 2001 From: MisRob Date: Thu, 22 Feb 2024 15:32:23 +0100 Subject: [PATCH 1/3] Add action to notify us on Slack about GH issues comments from contributors community --- .github/workflows/notify_team_new_comment.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/notify_team_new_comment.yml diff --git a/.github/workflows/notify_team_new_comment.yml b/.github/workflows/notify_team_new_comment.yml new file mode 100644 index 0000000000..f80a8461e4 --- /dev/null +++ b/.github/workflows/notify_team_new_comment.yml @@ -0,0 +1,35 @@ +name: Send a slack notification when a contributor comments on issue + +on: + issue_comment: + types: [created] + +jobs: + contributor_issue_comment: + name: Contributor issue comment + + if: >- + ${{ + !github.event.issue.pull_request && + github.event.comment.author_association != 'MEMBER' && + github.event.comment.author_association != 'OWNER' + }} + + runs-on: ubuntu-latest + steps: + - name: Escape title double quotes + id: escape_title + run: | + title=${{ github.event.issue.title }} + echo "ISSUE_TITLE=${title//\"/\\\"}" >> "$GITHUB_OUTPUT" + + - name: Send message to Slack channel + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + uses: slackapi/slack-github-action@v1.25.0 + with: + payload: | + { + "text": "*[Studio] New comment on issue: <${{ github.event.issue.html_url }}#issuecomment-${{ github.event.comment.id }}|${{ steps.escape_title.outputs.ISSUE_TITLE }} by ${{ github.event.comment.user.login }}>*" + } From da6f6865872a181b75a2cd70e3c08fa7fad070a8 Mon Sep 17 00:00:00 2001 From: MisRob Date: Fri, 23 Feb 2024 12:33:45 +0100 Subject: [PATCH 2/3] Use toJSON --- .github/workflows/notify_team_new_comment.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/notify_team_new_comment.yml b/.github/workflows/notify_team_new_comment.yml index f80a8461e4..0a23f9e0c1 100644 --- a/.github/workflows/notify_team_new_comment.yml +++ b/.github/workflows/notify_team_new_comment.yml @@ -20,8 +20,7 @@ jobs: - name: Escape title double quotes id: escape_title run: | - title=${{ github.event.issue.title }} - echo "ISSUE_TITLE=${title//\"/\\\"}" >> "$GITHUB_OUTPUT" + echo "ISSUE_TITLE=${{ toJSON(github.event.issue.title) }}" >> "$GITHUB_OUTPUT" - name: Send message to Slack channel env: From c36a1c43c931a231450fbc470a9defb1e9cd5f6e Mon Sep 17 00:00:00 2001 From: MisRob Date: Mon, 4 Mar 2024 14:14:32 +0100 Subject: [PATCH 3/3] Fix the action --- .github/workflows/notify_team_new_comment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/notify_team_new_comment.yml b/.github/workflows/notify_team_new_comment.yml index 0a23f9e0c1..5c4f675d09 100644 --- a/.github/workflows/notify_team_new_comment.yml +++ b/.github/workflows/notify_team_new_comment.yml @@ -20,7 +20,8 @@ jobs: - name: Escape title double quotes id: escape_title run: | - echo "ISSUE_TITLE=${{ toJSON(github.event.issue.title) }}" >> "$GITHUB_OUTPUT" + title='${{ github.event.issue.title }}' + echo "ISSUE_TITLE=${title//\"/\\\"}" >> "$GITHUB_OUTPUT" - name: Send message to Slack channel env: