-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (100 loc) · 3.21 KB
/
Copy pathslack-notify.yml
File metadata and controls
103 lines (100 loc) · 3.21 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Slack notify (reusable)
# Thin wrapper around .github/actions/slack-notify. Reusable workflows can read
# org secrets directly, so this wrapper is the natural way to call the action
# without forcing every caller to wire DEPLOY_BOT_SLACK_TOKEN / CI_SLACK_WEBHOOK
# at the job level.
#
# Defaults to the bot-token path (chat.postMessage), which returns ts so callers
# can thread or edit later. Webhook path stays as a fallback when no bot token
# is provisioned.
#
# Use cases:
# 1. Manual testing of the slack-notify action via the Actions tab
# (workflow_dispatch).
# 2. Callers that prefer `secrets: inherit` over wiring secrets at job level.
# Note the trade-off: each call spins up its own runner. For inline
# notifications inside an existing job, use the composite action directly.
on:
workflow_call:
inputs:
header:
type: string
required: true
color:
type: string
required: false
default: "good"
blocks:
type: string
required: false
default: ""
channel:
description: "Channel name or ID. Required for bot-token path."
type: string
required: false
default: ""
thread_ts:
description: "If set, post as a reply to this message ts."
type: string
required: false
default: ""
update_ts:
description: "If set, edit the message with this ts instead of posting a new one."
type: string
required: false
default: ""
outputs:
ts:
description: "Timestamp of the posted (or updated) message. Empty on webhook path."
value: ${{ jobs.send.outputs.ts }}
channel:
description: "Resolved channel ID. Empty on webhook path."
value: ${{ jobs.send.outputs.channel }}
workflow_dispatch:
inputs:
header:
type: string
required: true
default: "Test notification from slack-notify"
color:
type: string
required: false
default: "good"
blocks:
type: string
required: false
default: ""
channel:
type: string
required: false
default: "#dev"
thread_ts:
type: string
required: false
default: ""
update_ts:
type: string
required: false
default: ""
jobs:
send:
runs-on: ubuntu-latest
outputs:
ts: ${{ steps.notify.outputs.ts }}
channel: ${{ steps.notify.outputs.channel }}
steps:
# Composite action ref note: a reusable workflow can't easily resolve
# "the ref this workflow file was loaded from", so we pin the composite
# action to @main. Bump in tandem when cutting tagged releases.
- name: 💬 Send Slack notification
id: notify
uses: jitsucom/github-workflows/.github/actions/slack-notify@main
with:
bot_token: ${{ secrets.DEPLOY_BOT_SLACK_TOKEN }}
channel: ${{ inputs.channel }}
thread_ts: ${{ inputs.thread_ts }}
update_ts: ${{ inputs.update_ts }}
slack_webhook_url: ${{ secrets.CI_SLACK_WEBHOOK }}
header: ${{ inputs.header }}
color: ${{ inputs.color }}
blocks: ${{ inputs.blocks }}