Introduction

這是部落格架設紀錄系列的第貳篇,主要想著重在記錄 Quartz 的設定以及結合 GitHub Pages 部署的心(ㄒㄧㄝˇ)得(ㄌㄟˋ)。關於之前的系列文請見:

Quartz Setup

Configuration

Repository Setup

---
config:
  look: handDrawn
---
flowchart
orig_quartz[("jackyzha0/quartz")]
my_quartz[("mutichung/quartz")]
orig_quartz -- "pulls from upstream" --> my_quartz
dict[("mutichung/\_\_dict\_\_")]
my_quartz -- "contains submodule" --> dict
my_quartz -- "compiles submodule and hosts" --> webpage

Github Pages

Beyond the ordinary workflow of deploying to github pages, I made the following modifications to streamline my multi-repository setup:

  • When mutichung/__dict__ receives a new commit, an HTTP POST request will be sent to mutichung/quartz.

    .github/workflows/notify-update.yml
    name: Notify update
    on:
      push:  # Or whatever event you want to trigger on
      workflow_dispatch:
    jobs:
      dispatch:
        runs-on: ubuntu-latest
        steps:
          - name: Trigger repository_dispatch
            env:
              GITHUB_TOKEN: ${{ secrets.REPO_DISPATCH_TOKEN }}  # Store your PAT as a secret
            run: |
              curl -X POST \
                -H "Accept: application/vnd.github+json" \
                -H "Authorization: token $GITHUB_TOKEN" \
                https://api.github.com/repos/mutichung/mutichung.github.io/dispatches \
                -d '{"event_type":"update-event","client_payload":{"ref":"${{ github.ref }}","repo":"${{ github.repository }}"}}'
  • In the workflow of mutichung/quartz, a repository_dispatch trigger is set to listen to POST requests with an identical event_type from mutichung/__dict__.

    .github/workflows/update_content.yaml
      on:
        repository_dispatch:
          types: [update-event]
  • Once the workflow is triggered, it will

    1. Update submodule to the latest commit and push.
    2. Build the document.
    3. Deploy to Github Pages.