Skip to content

Fetch Hashnode Posts #12

Fetch Hashnode Posts

Fetch Hashnode Posts #12

name: Fetch Hashnode Posts
on:
push:
branches:
- main
schedule:
# Runs at 00:00 every day
- cron: '0 0 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
fetch-and-commit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Fetch Hashnode Posts
run: npm run fetch-blog
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add public/blog/posts.json
if git diff --staged --quiet; then
echo "No changes to commit. Skipping."
exit 0
fi
git commit -m "chore: auto-update hashnode posts"
git push