-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
64 lines (61 loc) · 2.18 KB
/
action.yaml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Notify Mattermost
description: An action to send notifications to mattermost.
author: Roberto Welzel Filho <[email protected]>
inputs:
webhook-url:
description: The URL of the mattermost webhook
required: true
username:
description: The username to be used.
required: true
default: github-actions
github-job:
description: 'The github job. Can be accessed using the following variable: "github.job"'
required: true
github-workflow:
description: 'The github workflow. Can be accessed using the following variable: "github.workflow"'
required: true
repository:
description: The repository for which the notificaiton should be sent.
required: true
run-id:
description: The ID of the run in which this notificaiton is being sent.
required: true
success-or-failure:
description: 'Use "success" if it was successful, anything else if it failed.'
required: true
runs:
using: 'composite'
steps:
- shell: bash
run: |
if [[ "${{ inputs.success-or-failure }}" == "success" ]]; then
SUCCESS_FAILURE="succeeded"
COLOR="#65cb8d"
else
SUCCESS_FAILURE="failed"
COLOR="#eb5b5c"
fi
curl '${{ inputs.webhook-url }}' -i -X POST \
-H 'Content-Type: application/json' \
-d '{
"username": "${{ inputs.username }}",
"attachments": [
{
"color": "'$COLOR'",
"text": "#### Deploy '$SUCCESS_FAILURE'\nJob `${{ inputs.github-job }}` '$SUCCESS_FAILURE' on ${{ inputs.github-workflow }} workflow.",
"fields": [
{
"short": true,
"title": "GitHub repository",
"value": "https://github.com/${{ inputs.repository }}"
},
{
"short": true,
"title": "GitHub Action run",
"value": "https://github.com/${{ inputs.repository }}/actions/runs/${{ inputs.run-id }}"
}
]
}
]
}'