-
Notifications
You must be signed in to change notification settings - Fork 22
50 lines (43 loc) · 1.39 KB
/
new-post-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
44
45
46
47
48
49
50
name: New Post Webhook
on:
push:
branches:
- "coal"
paths:
- "posts/**/post.mdx"
jobs:
notify:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/coal'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Find New post.mdx Files
id: check_new_files
run: |
NEW_POST=$(git diff --name-only --diff-filter=A HEAD^ HEAD | grep -o 'posts/[^/]*/post\.mdx' | sed 's|posts/\(.*\)/post\.mdx|\1|' | tail -n 1)
if [ -n "$NEW_POST" ]; then
echo "NEW_POST=$NEW_POST" >> $GITHUB_ENV
echo "new post: $NEW_POST"
else
echo "no new posts"
fi
- name: Set up Node.js
if: env.NEW_POST != ''
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install Dependencies
if: env.NEW_POST != ''
run: npm install
- name: Wait 5 minutes
if: env.NEW_POST != ''
run: sleep 300
- name: Send Webhook Notification
if: env.NEW_POST != ''
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"https://testausserveri.fi/syslog/${NEW_POST}\"}" $DISCORD_WEBHOOK_URL