How to Deploy Your Ghost Theme with GitHub Actions
Tags: ghost, cms, ghosttheme, deploy
Published: 2021-01-08 19:16:39

---
title: How to Deploy Your Ghost Theme with GitHub Actions
published: true
tags: 
- ghost
- cms
- ghosttheme
- deploy
canonical_url: https://bironthemes.com/blog/ghost-theme-deployment/
---

The Deploy Ghost Theme GitHub action is a great tool to improve the usual workflow when it comes to updating Ghost Themes. The most common way before was changing the theme files locally, then uploading the zip manually using the Ghost Admin.


But this tool is a much better way of doing theme deployment. I have been using the [Deploy Ghost Theme](https://github.com/marketplace/actions/deploy-ghost-theme) GitHub Action for the last couple of months and not only it is easy to setup, but this can save you a lot of time.

Let's see how you can setup this tool to automatically deploy your Ghost Theme whenever you are pushing changes to your theme repository on GitHub.

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#add-custom-ghost-integration)Add Custom Ghost Integration

First step is creating a new Custom Integration in **Ghost Admin > Integrations**. Name your integration, then press `Create`.

![Ghost Admin Custom Integration](https://bironthemes.com/static/d8f0d6123fee06aab3ddbdc986f7afcd/dadad/integrations-custom.png "Ghost Admin Custom Integration")

This will generate the `Admin API Key` and `Api URL` that will be used in the next step.

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#add-github-repo-secrets)Add GitHub Repo Secrets

Now, go to your theme repo on Github and go to **Settings > Secrets** Create two new secrets:

- `GHOST_ADMIN_API_KEY` - use the Custom Integration value **Admin API Key**
- `GHOST_ADMIN_API_URL` - use the Custom Integration value **Api URL**

![Github Secrets Ghost CMS](https://bironthemes.com/static/f34ceccf9ce21fabe4bdd741345ed3bf/dadad/github-secrets-ghost.png "Github Secrets Ghost CMS")

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#add-github-deploy-config)Add GitHub Deploy Config

Once the Custom Integration and the GitHub Secrets are in place you have to add the config file which contains the basic configuration.

Copy and paste the following code into `.github/workflows/deploy-theme.yml`

``` yaml
name: Deploy Theme
on:
  push:	
    branches:	
      - master
      - main
jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: Deploy Ghost Theme
        uses: TryGhost/action-deploy-theme@v1.4.1
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
```

This configuration will trigger a deployment for every commit which is pushed to the master branch. You have the possibility to customize the "on" trigger to different branches, pull requests or more. To find out more, check out the official [GitHub Action Documentation](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#on).

Besides the `api-url` and `api-key` there are additional config options available:

- `exclude` - list files & folder you would like to exclude (defaults: gulpfile.js and dist/\* )
- `theme-name` - use this to override the theme-name set in package.json
- `file` - specify path to a built zip file (exclude and theme-name will be ignored)

That is it, now when you push a new commit to your repository, the deploy should be triggered, updating your theme.