From 3c832e033b7224ecb01fa6589c31c33d7e384cbb Mon Sep 17 00:00:00 2001 From: Julien Marcil Date: Tue, 3 Jun 2025 16:40:32 -0400 Subject: [PATCH] feat: slack alert action --- .github/actions/slack-alert/action.yml | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/actions/slack-alert/action.yml diff --git a/.github/actions/slack-alert/action.yml b/.github/actions/slack-alert/action.yml new file mode 100644 index 0000000..61ecef5 --- /dev/null +++ b/.github/actions/slack-alert/action.yml @@ -0,0 +1,66 @@ +name: Slack Alert +description: Send a Slack alert message + +inputs: + message: + description: The message to send to Slack + required: true + mrkdwn: + description: The markdown message to send to Slack + required: false + token: + description: The Slack bot token to use for api calls + required: true + channel: + description: The Slack channel to send the alert to + required: true + +runs: + using: composite + steps: + - name: Alert on Slack + id: slack + uses: slackapi/slack-github-action@v2.1.0 + with: + errors: true + method: chat.postMessage + token: ${{ inputs.token }} + payload: | + { + "channel": "${{ inputs.channel }}", + "text": "${{ inputs.message }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "${{ inputs.message }}" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ inputs.mrkdwn || inputs.message }}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + } + ] + }