Skip to content

Commit

Permalink
feat: new post webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnl committed Nov 6, 2024
1 parent 333ed98 commit d2b6563
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/new-post-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

- name: Find New post.mdx Files
id: check_new_files
run: |
git fetch origin main
NEW_POST=$(git diff --name-only --diff-filter=A HEAD~1 HEAD | grep -o 'posts/[^/]*/post\.mdx' | sed 's|posts/\(.*\)/post\.mdx|\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: Run Script
if: env.NEW_POST != ''
run: npx tsx scripts/new-post-webhook.ts ${{ env.NEW_POST }}
Loading

0 comments on commit d2b6563

Please sign in to comment.