sumarsono.com
Take it with a grain of salt


Tahun Baru Wajah Baru: Monorepo, SSG Engine Baru, Theme Baru

Posted on

Mengawali tahun baru 2023, aku putuskan untuk mencoba hal baru:

Ngomong-ngomong Cloudflare Pages ini cukup straight forward ketika combine dengan github action. Cukup bikin project di cloudflare page, setup custom domain di cloudflare page, generate token profile cloudflare, bikin github action di github repo dan selesai.

Berikut ini contoh github action untuk deploy ssg zola ke cloudflare pages

cat .github/workflows/zola.yml
name: "Zola: build the website and publish to cloudflare page"

on:
  # detect push event in branch monorepo and change directory zola
  push:
    branches: 
      - monorepo
    paths:
      - "zola/**"
  # detect push event in branch monorepo and change directory zola
  pull_request:
    branches:
      - monorepo
    paths:
      - "zola/**"

  # allow to trigger manually via dashboard
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-22.04

    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}

    steps:
      - name: Git checkout and update theme
        uses: actions/[email protected]
        with:
          submodules: true
          fetch-depth: 0

      - name: Install and run zola build
        run: |
          sudo snap install --edge zola
          cd zola
          zola build --base-url https://www.sumarsono.com
      
      - name: Publish to cloudflare pages
        uses: cloudflare/[email protected]
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          command: pages publish zola/public --project-name=zola --commit-dirty=true --branch=main

Happy new year 2023!