Using Github Actions to deploy theme updates to Ghost Pro

I’m new here and wanted to share something with the community to help others learn to set up the theme auto-deploy GitHub action.

It’s important to note that if you are using Ghost Pro hosting and attempting to use the “stock” GitHub actions file displayed here, you will also need to add a step to convert your theme files into a zip file.

Here’s how to do it in the deploy-theme.yml file.

`name: Deploy Theme
on:
push:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

  - name: Zip theme files
    run: zip -r theme.zip .

  - name: Deploy Ghost Theme to Ghost Pro
    uses: TryGhost/action-deploy-theme@v1
    with:
      api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
      api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
      theme-name: "Custom Theme"
      file: ./theme.zip

`

Additional notes:

  • When setting up the github repo, I placed the package.json at the same level as the index.hbs file so you will notice that we are running the zip command at the root level of the directory.