@@ -10,35 +10,97 @@ jobs:
1010 context :
1111 runs-on : ubuntu-latest
1212
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+
1324 steps :
1425 - uses : actions/checkout@v4
1526 - 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
1668
1769 slack_notification :
1870 needs : context
1971 strategy :
2072 matrix :
2173 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 }}
2897 event : ' push'
2998 conclusion : ' failure'
3099 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 }}
42104
43105 runs-on : ubuntu-latest
44106 steps :
@@ -47,9 +109,12 @@ jobs:
47109 with :
48110 slack_token : ${{ secrets.SLACK_TOKEN }}
49111 slack_channel : ${{ secrets.SLACK_ADDONS_PRODUCTION_CHANNEL }}
112+ emoji : ${{ matrix.emoji }}
50113 actor : ${{ matrix.actor }}
51114 event : ${{ matrix.event }}
52115 conclusion : ${{ matrix.conclusion }}
53116 env : ${{ matrix.env }}
54117 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