-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (36 loc) · 1.56 KB
/
webhook.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
name: Discord Webhook Notif
# Notify the Discord channel when a push to main is published
on:
push:
branches:
- main
jobs:
deploy:
name: Run Webhook
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
# https://stackoverflow.com/a/64649397
# echo "COMMIT_NAME=$(python .github/workflows/parse_commit.py \"${{ github.event.head_commit.message }}\")" >> $GITHUB_ENV
- name: Dynamically set $DATE
run: echo "DATE=$(date +'%Y-%m-%dT%H:%M:%S.000Z')" >> $GITHUB_ENV
- name: Get github commit name
run: |
echo '${{ github.event.head_commit.message }}' > commit_msg.txt
echo "COMMIT_NAME=$(python .github/workflows/parse_commit.py commit_msg.txt)" >> $GITHUB_ENV
- name: Send webhook
env:
TITLE: ':rocket: New Commit on `main`!'
DESCRIPTION: '${{ env.COMMIT_NAME }}\n\n**Repo:** ${{ github.repository }}'
URL: 'https://github.com/${{ github.repository }}/commit/${{ github.sha }}'
# The backslashes around double quotes are annoying but if I use single quotes, discord will say the JSON is invalid for some reason
run: |
curl \
-H "Content-Type: application/json" \
-d "{ \"embeds\": [{ \"title\": \"$TITLE\", \"description\": \"$DESCRIPTION\", \"timestamp\": \"$DATE\", \"url\": \"$URL\" }]}" \
"${{ secrets.DISCORD_WEBHOOK_URL }}"