Deploying Your Ghost Theme Using GitHub Actions: A Step-by-Step Guide

As a Ghost theme developer, deploying your theme efficiently and effectively ensures a seamless experience for your users. GitHub Actions, a powerful automation tool, can simplify the deployment process by automating tasks such as building, testing, and deploying your theme. This guide will walk you through the steps to deploy your Ghost theme using GitHub Actions.

Prerequisites

Before we begin, make sure you have the following in place:

Set Up GitHub Actions

Configure the Workflow

Add the following code in the deploy-theme.yml file:

# Learn more → https://github.com/TryGhost/action-deploy-theme#getting-started
name: Deploy Theme
on:
  push:
    branches:
      - master
      - main
jobs:
  deploy:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - 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 }}

To Customize the workflow, you can replace the main with the branch name you want to trigger the deployment from (e.g., master).

Set Up Ghost API Credentials

Add Secrets to Your Repository

GHOST_ADMIN_API_URL: Paste the copied API URL.
GHOST_ADMIN_API_KEY: Paste the generated API key.

Deployment

Once the changes are pushed, GitHub Actions will automatically trigger the deployment workflow. You can monitor the deployment process by navigating to the “Actions” tab in your repository. Once the workflow completes successfully, your Ghost theme will be deployed to your Ghost CMS instance.

By leveraging the power of GitHub Actions, you can streamline the deployment process for your Ghost theme. Automating the build and deployment tasks saves time and ensures consistency and reliability.