From 8b709ff5bc7d4dcd484a7aed58825cbb62ea783a Mon Sep 17 00:00:00 2001 From: Jeff Titus <104520263+jeffreytitus@users.noreply.github.com> Date: Tue, 7 May 2024 21:51:53 -0700 Subject: [PATCH] Create notify-slack-on-issue.yml adding workflow to send messages to tq42-crypto-support channel in Slack when Issues or Comments on existing Issues are submitted --- .github/workflows/notify-slack-on-issue.yml | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/notify-slack-on-issue.yml diff --git a/.github/workflows/notify-slack-on-issue.yml b/.github/workflows/notify-slack-on-issue.yml new file mode 100644 index 0000000..70130da --- /dev/null +++ b/.github/workflows/notify-slack-on-issue.yml @@ -0,0 +1,24 @@ +name: GitHub Issue Notification to Slack + +on: + issues: + types: [opened, edited] + issue_comment: + types: [created] + +jobs: + notifySlack: + runs-on: ubuntu-latest + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + SLACK_CHANNEL: 'C071XET3G4S' + steps: + - name: Notify Slack on Issue or Comment + run: | + if [ "${{ github.event_name }}" == "issues" ]; then + PAYLOAD='{"channel":"'"$SLACK_CHANNEL"'","text":"New or edited issue: <${{ github.event.issue.html_url }}|${{ github.event.issue.title }}>"}' + elif [ "${{ github.event_name }}" == "issue_comment" ]; then + PAYLOAD='{"channel":"'"$SLACK_CHANNEL"'","text":"New comment on issue <${{ github.event.issue.html_url }}|${{ github.event.issue.title }}> by @${{ github.event.comment.user.login }}:\n<${{ github.event.comment.html_url }}|View Comment>"}' + fi + + curl -X POST -H 'Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}' -H 'Content-type: application/json; charset=utf-8' --data "$PAYLOAD" https://slack.com/api/chat.postMessage