-
Notifications
You must be signed in to change notification settings - Fork 2
40 lines (38 loc) · 1.34 KB
/
webhook_discord.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
name: Notify Discord of GitHub activity
on:
discussion:
types: [ created, answered ]
discussion_comment:
pull_request:
types: [ opened, reopened, closed ]
branches: [ main, dev ]
issue_comment:
types: [ created ]
issues:
types: [ opened, deleted, closed, reopened ]
release:
types: [ published ]
# Add other events here that you want to trigger the workflow on
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11.3
- name: Install dependencies
run: pip install requests
- name: Process webhook payload and notify Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
payload=$(cat $GITHUB_EVENT_PATH)
event_type=$(jq -r ".\"${{ github.event_name }}\"" <<< $payload)
repository_name=$(jq -r '.repository.name' <<< $payload)
sender_username=$(jq -r '.sender.login' <<< $payload)
message="New event on $repository_name by $sender_username! <@&1048243176999235637>"
payload=$(jq --arg message "$message" '. + {content: $message}' <<< $payload)
curl -H "Content-Type: application/json" -X POST -d "$payload" $DISCORD_WEBHOOK_URL