-
Notifications
You must be signed in to change notification settings - Fork 19
66 lines (60 loc) · 2.11 KB
/
deploy-notify.yml
File metadata and controls
66 lines (60 loc) · 2.11 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
name: Deploy Notification
on:
push:
branches: [production]
jobs:
notify:
name: Discord Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Build commit summary
id: info
run: |
BEFORE="${{ github.event.before }}"
HEAD="${{ github.sha }}"
SHORT_HEAD="$(git rev-parse --short HEAD)"
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
LOG="$(git log -1 --pretty='%h %s (%an)')"
COUNT=1
else
COUNT="$(git rev-list --count "${BEFORE}..${HEAD}")"
LOG="$(git log --pretty='%h %s (%an)' "${BEFORE}..${HEAD}" | head -15)"
if [ "$COUNT" -gt 15 ]; then
LOG="${LOG}
...and $((COUNT - 15)) more"
fi
fi
{
echo "log<<DELIM"
echo "$LOG"
echo "DELIM"
} >> "$GITHUB_OUTPUT"
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
echo "short_sha=$SHORT_HEAD" >> "$GITHUB_OUTPUT"
- name: Notify Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DEPLOY_LOG: ${{ steps.info.outputs.log }}
COMMIT_COUNT: ${{ steps.info.outputs.count }}
SHORT_SHA: ${{ steps.info.outputs.short_sha }}
COMPARE_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.sha }}
run: |
jq -n \
--arg title "Wasteland deployed to production" \
--arg desc "$DEPLOY_LOG" \
--arg count "$COMMIT_COUNT commit(s)" \
--arg sha "$SHORT_SHA" \
--arg url "$COMPARE_URL" \
'{embeds: [{
title: $title,
description: $desc,
color: 5025616,
fields: [
{name: "Commits", value: $count, inline: true},
{name: "Head", value: $sha, inline: true}
],
url: $url
}]}' | curl -fsSL -H "Content-Type: application/json" -d @- "$DISCORD_WEBHOOK"