Last active
March 7, 2024 21:49
-
-
Save davenicoll/b3e4f37b2ed4cf9876386ae26898a5bd to your computer and use it in GitHub Desktop.
Publish Ghost CMS from a private GitHub repo to a public Github Pages repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Ghost, generate static content, and publish to github pages | |
on: | |
push: | |
branches: [main] | |
jobs: | |
deploy: | |
concurrency: ci-${{ github.ref }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Run Ghost 👻 | |
run: docker run -d -p 2368:2368 -e NODE_ENV=development -e database__connection__filename='/var/lib/ghost/content/data/ghost.db' --name "ghost" -v ${{ github.workspace }}/content:/var/lib/ghost/content ghost:latest | |
# - name: Debug | |
# run: | | |
# echo "Debug..." | |
# sleep 10 | |
# docker container ls -a | |
# ID=$(docker inspect --format="{{.Id}}" ghost) | |
# echo "Logs ($ID)..." | |
# docker logs "$ID" | |
- name: Sleep for 10 seconds 💤 | |
uses: jakejarvis/wait-action@master | |
with: | |
time: "10s" | |
- name: Install ghost-static-site-generator ✨ | |
run: npm install -g ghost-static-site-generator | |
- name: Generate Static Site 🛠️ | |
run: gssg --url https://your-domain.com | |
- name: Deploy to Github Pages 🚀 | |
uses: JamesIves/[email protected] | |
with: | |
branch: main #gh-pages | |
folder: static | |
token: ${{ secrets.DEPLOY_PAT }} | |
repository-name: your-github-username/your-github-username.github.io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions -
yoursite
- this is the private repository you'll store your site in, containing ghost, themes, etc.your-site.github.io
- this is the repo we'll publish from ghost toDEPLOY_PAT
to theyour-site
repo (https://github.com/your-github-username/your-site/settings/secrets/actions
)CNAME
to the root ofyour-site.github.io
, containing your domain name to enable github pages to server content for your domain (see here for help).github/workflows
in theyoursite
repodockerhub.com/ghost/ghost:latest
, and mount/content
within theyoursite
repo to/var/lib/ghost/content
yoursite
repo. The github action will publish your changes toyour-site.github.io
, and after a few minutes, you'll be able to see the changes