-
Notifications
You must be signed in to change notification settings - Fork 798
65 lines (61 loc) · 2.08 KB
/
slack-branch-existence-notification.yml
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
name: Slack branch existence notification
on:
create:
delete:
jobs:
notify:
name: Notify
runs-on: ubuntu-latest
timeout-minutes: 5 # 2022-11-22: Shouldn't take long.
if: github.event.ref == 'prerelease'
steps:
- uses: actions/checkout@v4
with:
ref: trunk
- name: Generate message
id: message
run: |
source .github/files/gh-funcs.sh
if [[ "$GITHUB_EVENT_NAME" == 'create' ]]; then
gh_set_output message "$(
jq -nc --slurpfile event "$GITHUB_EVENT_PATH" '$event[0] as $e | {
icon_emoji: ":lock:",
text: "Incoming release! Prerelease branch was created by \( $e.sender.login ).",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: ":holdontoyourbutts: Incoming release! Prerelease branch was created by \( $e.sender.login ).",
},
}
],
}'
)"
elif [[ "$GITHUB_EVENT_NAME" == 'delete' ]]; then
gh_set_output message "$(
jq -nc --slurpfile event "$GITHUB_EVENT_PATH" '$event[0] as $e | {
icon_emoji: ":unlock:",
text: "Prerelease branch was deleted by \( $e.sender.login ).",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "Prerelease branch was deleted by \( $e.sender.login ).",
},
}
],
}'
)"
else
echo "::error::Unknown event \"$GITHUB_EVENT_NAME\""
exit 1
fi
- name: Send message to releases channel
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_RELEASES_CHANNEL }}
payload: ${{ steps.message.outputs.message }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}