Skip to content

Daily Blog Generator #127

Daily Blog Generator

Daily Blog Generator #127

name: Daily Blog Generator
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: "write"
pages: "write"
id-token: "write"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run blog generator
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: pnpm generate-blog
- name: Build project
run: pnpm build
- name: Commit and push generated content
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git commit -m "[skip-ci] Daily blog update ($(date))" || echo "[skip-ci] No changes to commit"
git push
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload build directory content
path: "dist/"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}