Skip to content

Celebrating our new site: 30% off everything with code , until Dec 1.

Bright Themes

How to deploy your Ghost theme with GitHub Actions

Upload your Ghost theme to your site automatically every time you push to GitHub, with Ghost's official Deploy Ghost Theme action.

Norbert3 min read

Without automation, every theme change means zipping the folder and uploading it in Ghost Admin. Ghost’s official Deploy Ghost Theme (opens in a new tab) action does it for you: push to GitHub, and the action zips the theme and uploads it to your site through the Ghost Admin API. We’ve used it for years, and it saves a lot of repetitive work.

What you need

  • Your theme in a GitHub repository.
  • An Owner or Administrator login for your Ghost site, to create an integration. It works on Ghost(Pro) from the Publisher plan up, and on self-hosted sites.

1. Create a custom integration in Ghost

  1. In Ghost Admin, open Settings › Advanced › Integrations.
  2. Choose Add custom integration, enter a Name such as “GitHub theme deploy”, and choose Add.
  3. Ghost opens the new integration, with its Content API key, Admin API key and API URL. Keep it open: you need the last two in the next step.

2. Add the keys as GitHub secrets

  1. In your theme’s repository on GitHub, open the Settings tab.
  2. In the sidebar, under Security, open Secrets and variables, then Actions.
  3. On the Secrets tab, choose New repository secret. Enter GHOST_ADMIN_API_URL as the Name, paste the integration’s API URL as the Secret, and choose Add secret.
  4. Do the same for GHOST_ADMIN_API_KEY, with the integration’s Admin API key.

Copy the values exactly. The two secrets are then listed by name on the Secrets tab.

Secrets stay hidden in the logs, and nobody can read them back from the repository.

3. Add the workflow file

Create .github/workflows/deploy-theme.yml in your repository with:

YAML
name: Deploy Theme
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy Ghost Theme
        uses: TryGhost/action-deploy-theme@v1
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}

This deploys the theme on every push to main. Use your own branch name if it differs, for example master. To deploy on other events, such as a published release or a manual run, see GitHub’s workflow trigger docs (opens in a new tab).

The action’s options, besides api-url and api-key:

  • exclude: files and folders to leave out of the zip, as a space-separated list, for example "gulpfile.js src/*". It adds to the defaults, which already leave out node_modules, Git files, zip files, yarn*, npm* and pnpm* files, routes.yaml, redirects.yaml and redirects.json.
  • theme-name: a theme name that overrides the name in package.json. The action names the zip after it, and Ghost names the theme after the zip.
  • file: the path to a zip you built in an earlier step. With it, exclude and theme-name are ignored.
  • working-directory: the folder to zip, when the theme sits in a subfolder of the repository.
  • version: the lowest Ghost Admin API version the action expects from your site. It defaults to v6.0.

If your theme builds its CSS and JavaScript (our themes do: each theme’s docs list the build commands), add the build steps before Deploy Ghost Theme, or commit the built files, so the zip contains them.

4. Push and check the deploy

Commit the workflow file and push it. Open the Actions tab of your repository to follow the run. When it’s green, the theme is uploaded.

Ghost replaces the installed theme with the same name. If it’s your active theme, your site uses the new version right away, and your design settings stay as they are, because the name didn’t change. See Keep your design settings when you update a Ghost theme.

Tip

Check the theme with GScan before you push to the branch that deploys. A theme with fatal errors won’t upload.

The result

Every push to your main branch now updates your live theme, with no zipping and no manual uploads. To update one of our themes with this setup, see How to update your Ghost theme to a new version.

Related posts

More on themes

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.