Skip to content

Github Action Deployment

Eduardo Gómez edited this page Jan 11, 2020 · 2 revisions

First of all thanks to D3473R for this! 🙏🏼 This page contains basically the instructions he wrote in his PR.

Thanks to GitHub Actions you can build and deploy this theme automatically to your Ghost instance when you push to master. Here's how you can do it:

  1. Generate a set of Ghost Admin API credentials, by configuring a new Custom Integration in Ghost Admin»Integrations.

  2. On GitHub, navigate to your theme repository»Settings»Secrets. Create a secret called GHOST_ADMIN_API_URL containing the API URL and another called GHOST_ADMIN_API_KEY containing the Admin API Key. Both must be copied exactly from Ghost Admin»Integrations.

  3. Create a file .github/workflows/deploy-theme.yml with the contents:

name: Deploy Theme
on: [push]

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master
      - uses: actions/setup-node@v1
        with:
          node-version: '10.x'
      - run: npm install
        working-directory: ./src
      - name: Build and deploy the theme
        working-directory: ./src
        run: npm run deploy
        env:
          GHOST_ADMIN_API_URL: ${{ secrets.GHOST_ADMIN_API_URL }}
          GHOST_ADMIN_API_KEY: ${{ secrets.GHOST_ADMIN_API_KEY }}

You're all set! From now on when you push to master the theme will be built and deployed automatically to your ghost instance 🚀

Manual deployment is also possible:

  1. Copy .env.example to .env

  2. Enter your GHOST_ADMIN_API_URL and GHOST_ADMIN_API_KEY in the .env file (Not in the .env.example file!!! Because this file is tracked with git and your secrets would be uploaded to your git repo)

  3. Run npm run deploy in the src directory