Skip to content

Commit 3eb37fb

Browse files
committed
Add Slack alert GitHub action
1 parent 6102695 commit 3eb37fb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Slack alert
3+
description: Send an alert to a Slack channel
4+
inputs:
5+
inputs:
6+
description: Textual representation of workflow inputs
7+
required: false
8+
default: "N/A"
9+
type: string
10+
message:
11+
description: Alert message
12+
required: false
13+
default: "${{ github.workflow }} GitHub Actions workflow failed :sob:"
14+
type: string
15+
results-url:
16+
description: URL for workflow results
17+
required: false
18+
default: "N/A"
19+
type: string
20+
runs:
21+
using: composite
22+
steps:
23+
- name: Send message to Slack via Workflow Builder
24+
uses: slackapi/[email protected]
25+
with:
26+
payload: |
27+
{
28+
"channel-id": "${{ env.SLACK_CHANNEL_ID }}",
29+
"inputs": "${{ env.INPUTS }}",
30+
"message": "${{ env.MESSAGE }}",
31+
"results-url": "${{ env.RESULTS_URL }}",
32+
"workflow-url": "${{ env.WORKFLOW_URL }}"
33+
}
34+
env:
35+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
36+
SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}
37+
INPUTS: ${{ inputs.inputs }}
38+
MESSAGE: ${{ inputs.message }}
39+
RESULTS_URL: ${{ inputs.results-url }}
40+
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

0 commit comments

Comments
 (0)