Creating a staging - production workflow for Ghost: questions re: implementation?

Hello Ghost-using friends!

This topic has been covered in the community forums before. But the last thread I found was a few years ago. I think that this is an extremely important question for users so I hope you’ll indulge me in revisiting the topic.

I love Ghost CMS but for using it for a professional context, I can’t afford to take risks in “moving fast and breaking things.” A staging environment would be essential, especially when modifying themes.

I have installed Ghost with ease on VPSes but have little experience in manually provisioning something like a staging workflow / CI:CD pipeline.

A few questions:

  • Are there any Ghost-friendly hosts that can automatically provision the staging environment? This exists quite widely in the Wordpress ecosystem.

  • If not, for those trying to achieve this manually, can anyone recommend what tools they have had success with? I’m guessing that Git is an essential component but perhaps it doesn’t need to be more complicated than pushing the Ghost folder, when desired, between two VPSes.

Thanks in advance for thoughts!

1 Like

The answer to this will depend a bit on what you want to stage:

  • Content
  • Themes
  • Customized version of Ghost

Answering that will be helpful to know how to respond.

1 Like

Hi Ryan,

I imagine that - like most users I’m guessing - the “potentially breaking” updates that would be useful to stage would be theme modifications.

The rest (post authoring, etc) I would classify as “far less likely to break things!”

:slight_smile:

Daniel

If it’s just about theme modifications, I could imagine a workflow like this:

You set up two Ghost sites. One for production, one for staging. Potentially consider some sample content that tests all styles etc. for the staging one. These can also run on the same machine – at least, I don’t see a benefit of running them on two separate ones.

For the theme you’re testing, I’d set up a Github repository, if you haven’t and use the Github Action to deploy themes.

Now, the example in there will automatically run. So, set up the set of secrets for the staging environment.

Then set up a second Github action, but like this:

name: Deploy Theme
on:
  workflow_dispatch

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.PROD_GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.PROD_GHOST_ADMIN_API_KEY }}

You’ll need a second pair of secrets (for your production environment), as you can see.

That workflow is set up to run on workflow_dispatch – so, just manual when you click a button in Github.

So, when you’re satisfied with your changes on your staging environment, go to the Github actions in your repository and click the “Run workflow” button there (or use the API to trigger it). A few moments later, the new theme should be on your production environment.

Haven’t tested this with themes, but that’s is the principle (with different custom Github actions) of how I deploy new Ghost versions on Magic Pages.

2 Likes

@jannis

Thanks so much for putting so much thought into this (yes, I’ve used Github Actions but not yet in a production use-case).

I will try your suggestion next week and (of course) report back to the community!

Cordially,

Daniel

1 Like