You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: Add image and another example
Include a link to vault-helm usage for in-the-wild examples.
Explain what the job status variables are and when to use them.
Co-authored-by: brian shore <[email protected]>
Release Engineering may provision one on your behalf for status notifications from our [Release Bot](https://api.slack.com/apps/A034FRWL0RK/incoming-webhooks).
12
23
13
-
To use, add a step like:
24
+
Do *not* use Slack's Workflow Builder integration to generate the webhook link.
25
+
26
+
2. Add the step to the workflow
27
+
28
+
To use, add a step that tests the job status (success, failure, cancelled):
14
29
15
30
```yaml
16
31
steps:
@@ -21,13 +36,14 @@ steps:
21
36
- uses: hashicorp/actions-slack-status@v1
22
37
if: ${{always()}}
23
38
with:
24
-
success-message: ":tada: A success message."
25
-
failure-message: ":boom: A failure message."
26
-
status: ${{job.status}
39
+
success-message: "A *bolded success* message."
40
+
failure-message: "A failure message."
41
+
#cancelled-message: "Operation cancelled, but that's okay!"
42
+
status: ${{job.status}}
27
43
slack-webhook-url: ${{secrets.slack_webhook_url}}
28
44
```
29
45
30
-
Or more advanced usage, pass a specific step conclusion:
46
+
Or more advanced usage with, pass a specific step conclusion (success, failure, cancelled, skipped):
31
47
32
48
```yaml
33
49
steps:
@@ -38,8 +54,41 @@ steps:
38
54
exit 0
39
55
- uses: hashicorp/actions-slack-status@v1
40
56
with:
41
-
skipped-message: ":skip: A successfully skipped cmd message."
42
-
success-message: ":tada: A success message."
57
+
skipped-message: "A successfully skipped `cmd` message."
58
+
success-message: "A success message."
43
59
status: ${{steps.demo.conclusion}}
44
60
slack-webhook-url: ${{secrets.slack_webhook_url}}
45
61
```
62
+
63
+
64
+
Note: Normally, if a `${status}-message` is not defined for a given status a
65
+
GH warning will be emitted on the action and no message will be sent to slack.
66
+
To avoid this, one can use an approprate `if` statement to skip this step.
67
+
68
+
In this example, success messages are never sent and no GHA warning will be
69
+
emitted regarding this omission.
70
+
```yaml
71
+
steps:
72
+
- run: |
73
+
exit 0
74
+
- uses: hashicorp/actions-slack-status@v1
75
+
if: failure()
76
+
with:
77
+
failure-message: "Since our job never fails, this message will never send nor will it warn about a missing success-message field"
78
+
status: 'failure'
79
+
slack-webhook-url: ${{secrets.slack_webhook_url}}
80
+
```
81
+
82
+
### Job Status Meanings
83
+
84
+
In the examples we used different ways of obtaining the statuses. Their usage can be nuanced, but generally they are:
85
+
86
+
* [jobs.status docs](https://docs.github.com/en/actions/learn-github-actions/contexts#job-context): `success`, `failure`, or `cancelled`
87
+
* [steps.id.conclusion docs](https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context): `success`, `failure`, `cancelled`, or `skipped`
88
+
* [steps.id.outcome docs](https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context): `success`, `failure`, `cancelled`, or `skipped`
89
+
90
+
If in doubt, use `${{jobs.status}}`. The specific step status can be useful if we need to report skips or when multiple
91
+
steps are mutually exclusive, and we would like to notify exactly which one fired.
92
+
93
+
Step conclusion and outcome can differ depending on whether `continue-on-error` is set. In otherwords, if
94
+
a step's `continue-on-error: true`, the outcome may be `failure` or `success` but the conclusion would be `success`.
0 commit comments