/
action.yml
40 lines (39 loc) · 1.49 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: 'Workflow Status Slack Notification'
description: 'Send notifications to Slack about the status of a github workflow'
inputs:
slack-webhook:
description: 'Slack webhook URL'
required: true
slack-username:
description: 'Username to display in the message'
required: true
slack-channel:
description: 'Slack channel to post the message'
required: true
workflow-status:
description: 'The status of the workflow'
required: true
runs:
using: composite
steps:
- name: Notify Slack Channel
shell: bash
run: |
color="warning"
if [ "${{ inputs.workflow-status }}" == "failed" ]; then
color="danger"
elif [ "${{ inputs.workflow-status }}" == "succeeded" ]; then
color="good"
fi
curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" \
--data '{
"username": "${{ inputs.slack-username }}",
"channel": "${{ inputs.slack-channel }}",
"attachments": [
{
"title": "[${{ github.repository }}] ${{ github.workflow }} ${{ inputs.workflow-status }} on ${{ github.head_ref || github.ref_name }}",
"text": "*<https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha || github.sha }}|Commit>* *<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow>*",
"color": "'$color'"
}
]
}'