Skip to content

Fetch Hashnode Posts #2

Fetch Hashnode Posts

Fetch Hashnode Posts #2

name: Fetch Hashnode Posts
on:
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
git commit -m "chore: auto-update hashnode posts via cron job" || echo "No changes to commit"
git push