-
Notifications
You must be signed in to change notification settings - Fork 14.7k
39 lines (36 loc) · 1.36 KB
/
Copy pathdiscord.yml
File metadata and controls
39 lines (36 loc) · 1.36 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
name: Notify Discord on push
on:
push: # run on any branch; change if you want test again and again
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Compose message
id: compose
run: |
REPO="${{ github.repository }}"
BRANCH="${{ github.ref_name }}"
ACTOR="${{ github.actor }}"
URL="https://github.com/${REPO}/commits/${BRANCH}"
# Use \n inside the string; jq will escape correctly
echo "MSG=✅ Push to **${REPO}** on **${BRANCH}** by **${ACTOR}**\n${URL}" >> $GITHUB_ENV
# 🔎 DEBUG STEP (insert here)
- name: Minimal test to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
echo "Testing webhook with a simple message..."
curl -i -H "Content-Type: application/json" \
-d '{"content":"Hello from GitHub Actions 👋"}' \
"$DISCORD_WEBHOOK"
- name: Send to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
MSG: ${{ env.MSG }}
run: |
# Build valid JSON safely
payload=$(jq -nc --arg content "$MSG" '{content:$content}')
# Send and show status + any error body for debugging
curl -sS -i -H "Content-Type: application/json" \
-d "$payload" \
"$DISCORD_WEBHOOK"