@@ -10,35 +10,97 @@ jobs:
10
10
context :
11
11
runs-on : ubuntu-latest
12
12
13
+ outputs :
14
+ emoji : ${{ steps.ref.outputs.emoji }}
15
+ actor : ${{ steps.ref.outputs.actor }}
16
+ event : ${{ steps.ref.outputs.event }}
17
+ env : ${{ steps.ref.outputs.env }}
18
+ conclusion : ${{ steps.ref.outputs.conclusion }}
19
+ ref : ${{ steps.ref.outputs.ref }}
20
+ ref_link : ${{ steps.ref.outputs.ref_link }}
21
+ workflow_id : ${{ steps.ref.outputs.workflow_id }}
22
+ workflow_url : ${{ steps.ref.outputs.workflow_url }}
23
+
13
24
steps :
14
25
- uses : actions/checkout@v4
15
26
- uses : ./.github/actions/context
27
+ - id : ref
28
+ shell : bash
29
+ run : |
30
+ branch="${{ github.event.workflow_run.head_branch }}"
31
+ title="${{ github.event.workflow_run.display_title }}"
32
+ sha="${{ github.event.workflow_run.head_sha }}"
33
+ workflow_id="${{ github.event.workflow_run.id }}"
34
+ workflow_url="${{ github.event.workflow_run.html_url}}"
35
+ actor="${{ github.event.workflow_run.triggering_actor.login }}"
36
+ conclusion="${{ github.event.workflow_run.conclusion }}"
37
+
38
+ commit_short=$(echo "$sha" | cut -c1-7)
39
+
40
+ ref="$branch ($commit_short) $title"
41
+ event="${{ github.event.workflow_run.event}}"
42
+ repo_url="${{ github.server_url }}/${{ github.repository }}"
43
+
44
+ if [[ "$event" == "push" ]]; then
45
+ env="dev"
46
+ ref_link="$repo_url/commit/$sha"
47
+ elif [[ "$event" == "release" ]]; then
48
+ env="production"
49
+ ref_link="$repo_url/releases/tag/$head_branch"
50
+ fi
51
+
52
+ if [[ "$conclusion" == "success" ]]; then
53
+ emoji=":white_check_mark:"
54
+ else
55
+ emoji=":x:"
56
+ fi
57
+
58
+ echo "emoji=$emoji" >> $GITHUB_OUTPUT
59
+ echo "actor=$actor" >> $GITHUB_OUTPUT
60
+ echo "event=$event" >> $GITHUB_OUTPUT
61
+ echo "conclusion=$conclusion" >> $GITHUB_OUTPUT
62
+ echo "env=$env" >> $GITHUB_OUTPUT
63
+ echo "ref=$ref" >> $GITHUB_OUTPUT
64
+ echo "ref_link=$ref_link" >> $GITHUB_OUTPUT
65
+ echo "workflow_id=$workflow_id" >> $GITHUB_OUTPUT
66
+ echo "workflow_url=$workflow_url" >> $GITHUB_OUTPUT
67
+ cat $GITHUB_OUTPUT
16
68
17
69
slack_notification :
18
70
needs : context
19
71
strategy :
20
72
matrix :
21
73
include :
22
- - actor : ${{ github.event.workflow_run.actor.login }}
23
- event : ' push'
24
- conclusion : ' success'
25
- env : ' dev'
26
- ref : ${{ github.event.workflow_run.head_commit.id }}
27
- - actor : ${{ github.event.workflow_run.actor.login }}
74
+ # The real message based on the context of the workflow
75
+ - emoji : ${{ needs.context.outputs.emoji }}
76
+ actor : ${{ needs.context.outputs.actor }}
77
+ event : ${{ needs.context.outputs.event }}
78
+ conclusion : ${{ needs.context.outputs.conclusion }}
79
+ env : ${{ needs.context.outputs.env }}
80
+ ref : ${{ needs.context.outputs.ref }}
81
+ ref_link : ${{ needs.context.outputs.ref_link }}
82
+ workflow_id : ${{ needs.context.outputs.workflow_id }}
83
+ workflow_url : ${{ needs.context.outputs.workflow_url }}
84
+ # No Emoji
85
+ - emoji : ' '
86
+ actor : ${{ needs.context.outputs.actor }}
87
+ event : ${{ needs.context.outputs.event }}
88
+ conclusion : ${{ needs.context.outputs.conclusion }}
89
+ env : ${{ needs.context.outputs.env }}
90
+ ref : ${{ needs.context.outputs.ref }}
91
+ ref_link : ${{ needs.context.outputs.ref_link }}
92
+ workflow_id : ${{ needs.context.outputs.workflow_id }}
93
+ workflow_url : ${{ needs.context.outputs.workflow_url }}
94
+ # Custom Emoji and ref
95
+ - emoji : ' :party_blob:'
96
+ actor : ${{ github.event.workflow_run.actor.login }}
28
97
event : ' push'
29
98
conclusion : ' failure'
30
99
env : ' dev'
31
- ref : ${{ github.event.workflow_run.head_commit.id }}
32
- - actor : ${{ github.event.workflow_run.actor.login }}
33
- event : ' release'
34
- conclusion : ' success'
35
- env : ' production'
36
- ref : 2025.01.01
37
- - actor : ${{ github.event.workflow_run.actor.login }}
38
- event : ' release'
39
- conclusion : ' failure'
40
- env : ' production'
41
- ref : 2025.01.01
100
+ ref : ' It is time to party!'
101
+ ref_link : ${{ needs.context.outputs.ref_link }}
102
+ workflow_id : ${{ needs.context.outputs.workflow_id }}
103
+ workflow_url : ${{ needs.context.outputs.workflow_url }}
42
104
43
105
runs-on : ubuntu-latest
44
106
steps :
@@ -47,9 +109,12 @@ jobs:
47
109
with :
48
110
slack_token : ${{ secrets.SLACK_TOKEN }}
49
111
slack_channel : ${{ secrets.SLACK_ADDONS_PRODUCTION_CHANNEL }}
112
+ emoji : ${{ matrix.emoji }}
50
113
actor : ${{ matrix.actor }}
51
114
event : ${{ matrix.event }}
52
115
conclusion : ${{ matrix.conclusion }}
53
116
env : ${{ matrix.env }}
54
117
ref : ${{ matrix.ref }}
55
- workflow_id : ${{ github.event.workflow_run.id }}
118
+ ref_link : ${{ matrix.ref_link }}
119
+ workflow_id : ${{ matrix.workflow_id }}
120
+ workflow_url : ${{ matrix.workflow_url }}
0 commit comments