Build blog pages #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build blog pages | |
| on: | |
| workflow_dispatch: | |
| env: | |
| CLOUDFLARE_PAGES_PROJECT_NAME: ${{ secrets.CLOUDFLARE_PAGES_PROJECT_NAME }} | |
| NOTION_SECRET: ${{ secrets.NOTION_SECRET }} | |
| NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }} | |
| GISCUS_REPO: ${{ secrets.GISCUS_REPO }} | |
| GISCUS_REPO_ID: ${{ secrets.GISCUS_REPO_ID }} | |
| GISCUS_CATEGORY: ${{ secrets.GISCUS_CATEGORY }} | |
| GISCUS_CATEGORY_ID: ${{ secrets.GISCUS_CATEGORY_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| HUGO_VERSION: 0.147.2 | |
| HUGO_ENVIRONMENT: production | |
| TZ: Asia/Shanghai | |
| steps: | |
| - name: Install Task | |
| uses: arduino/setup-task@v2 | |
| with: | |
| version: 3.x | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Hugo CLI | |
| run: | | |
| wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
| && sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
| - name: Install Dart Sass | |
| run: sudo snap install dart-sass | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install Node.js dependencies | |
| run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
| - name: Install notion-site | |
| run: |- | |
| cd /tmp | |
| curl -Lo notion-site.tar.gz https://github.com/nonacosa/notion-site/releases/download/v2.0.2/notion-site-linux-amd64.tar.gz | |
| tar xvf notion-site.tar.gz | |
| sudo mv notion-site /usr/bin | |
| sudo chmod +x /usr/bin/notion-site | |
| - name: Cache Restore | |
| id: cache-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ${{ runner.temp }}/hugo_cache | |
| key: hugo-${{ github.run_id }} | |
| restore-keys: | |
| hugo- | |
| - name: Configure Git | |
| run: git config core.quotepath false | |
| - name: Build Hugo site | |
| run: task clean notion:sync hugo:build | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: pages deploy public --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }} | |
| - name: Cache Save | |
| id: cache-save | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ${{ runner.temp }}/hugo_cache | |
| key: ${{ steps.cache-restore.outputs.cache-primary-key }} |