Using GitHub Action Deploy And Update Your Blog Theme

記錄我如何透過 Github Action 更新我的 Ghost Theme.

官方的文件有點久沒更新了

Official Ghost + GitHub Integration
Set up simple continuous integration of your Ghost theme to deploy directly to your Ghost website with GitHub Actions. Share code snippets with GitHub Gists 👨‍💻

有兩個地方需要修改

  1. github action branches 要改成 main
    因為現在 github default branch 都正名成 main
github/renaming
Guidance for changing the default branch name for GitHub repositories - github/renaming

2. TryGhost 的 version 要改用 1.4.x版本
並不能用官方教學的 1.0.0 因為 update theme 會遇到一個 theme-name 重複的 error

name: Deploy Theme
on:
  push:	
    branches:	
      - main
jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master
      - uses: TryGhost/[email protected]
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
          theme-name: my-theme