Recovering front-end developer, now I just write JavaScript

Build & Deploy Ghost Themes with GitHub Actions

How to have GitHub actions build your theme assets so you don't need to have built files in source control.

Build & Deploy Ghost Themes with GitHub Actions
Photo by JJ Ying / Unsplash

A while back, I was chatting with my colleague Ryan about Ghost theme deployment and how cool it would be to not need to commit built files to source control and have GitHub Actions build them and then deploy.

Ryan took that idea and ran with it. He wrote a really nice article about how to achieve just what I was after.

Build and Deploy with GitHub Actions
Let the machines take the wheel with GitHub Actions. Push an update to your Ghost theme and then see it automatically built and deployed, anywhere and everywhere.

I borrowed most of the code & ideas, and adapted it slightly to suit my needs. I use yarn instead of npm, so my version accounts for that and skips deploying to a demo site.

If you already use GitHub Actions to deploy your theme, you can probably drop this right in. You may need to adapt the build task, which is run: npm run build in this yaml file and "build": "gulp build", in the scripts in my package.json file.

name: Deploy Theme
      - main
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
      - name: Use Node.js
        uses: actions/setup-node@v3
          node-version: '18.x'
          cache: 'npm'
      - run: |
          if [ -e yarn.lock ]; then
          yarn install --frozen-lockfile
          elif [ -e package-lock.json ]; then
          npm ci
          npm i
      - run: npm run build
      - name: Deploy site
        uses: TryGhost/action-deploy-theme@v1
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}

I'm mostly sharing this incase anyone with the same setup as me is in a ind and needs a quick solution. Happy building!