Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copy to .env next to compose.yaml if you need non-default values.
# Do not commit a real .env file.

GHOST_PORT=2373
GHOST_URL=http://localhost:2373
# Bind-mount for themes, images, and the SQLite database (same role as ~/.ghost/content).
# GHOST_CONTENT=/home/you/.ghost/content
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ jobs:

- name: Run static validation fixture tests
run: bash tests/run-validation-tests.sh

- name: Run compose and workflow fixture tests
run: bash tests/run-compose-tests.sh

- name: Lint GitHub Actions workflows
run: |
bash <(curl --fail --silent --show-error --location https://raw.githubusercontent.com/rhysd/actionlint/914e7df21a07ef503a81201c76d2b11c789d3fca/scripts/download-actionlint.bash) 1.7.12
./actionlint -oneline

compose-smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Validate compose.yaml and boot Ghost
run: bash scripts/compose-smoke.sh --start
177 changes: 177 additions & 0 deletions .github/workflows/publish-static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Publish static site

# Reusable workflow: start Ghost (official image), run gssg, validate, optionally deploy Pages.
# Call from your blog repo — see examples/github/publish-static.yml and docs/v3/CI.md
# workflow_dispatch on this repository is a dry-run unless deploy_pages is true.

on:
workflow_call:
inputs:
production_domain:
description: Public blog URL (https://USER.github.io/REPO)
required: true
type: string
gh_username:
description: GitHub username (used for gssg --subDir)
required: true
type: string
gh_repo:
description: Pages repository name
required: false
type: string
default: ""
ghost_port:
required: false
type: string
default: "2373"
content_path:
description: Directory in the caller repo to mount as Ghost content (themes, images, SQLite)
required: false
type: string
default: "content"
scripts_repository:
required: false
type: string
default: paladini/ghost-on-github-pages
scripts_ref:
required: false
type: string
default: master
deploy_pages:
required: false
type: boolean
default: true
allow_empty:
description: Export even when the content directory is missing (publishes a fresh empty Ghost)
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
production_domain:
description: Public blog URL (https://USER.github.io/REPO)
required: true
type: string
gh_username:
description: GitHub username
required: true
type: string
gh_repo:
description: Pages repository name
required: false
type: string
default: ""
deploy_pages:
description: Deploy to GitHub Pages after export
required: false
type: boolean
default: false
allow_empty:
description: Export even when the content directory is missing
required: false
type: boolean
default: true

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages-${{ github.repository }}
# Match the GitHub Pages starter: do not cancel an in-progress production deploy.
cancel-in-progress: false

jobs:
export:
runs-on: ubuntu-latest
steps:
- name: Checkout caller repository
uses: actions/checkout@v4
with:
path: blog

- name: Checkout Ghost on GitHub Pages scripts
uses: actions/checkout@v4
with:
# Reusable calls default to this repo on master. workflow_dispatch uses the current commit.
repository: ${{ inputs.scripts_repository || (github.event_name == 'workflow_dispatch' && github.repository || 'paladini/ghost-on-github-pages') }}
ref: ${{ inputs.scripts_ref || (github.event_name == 'workflow_dispatch' && github.sha || 'master') }}
path: gogp

- name: Install wget and Node.js tools
run: |
sudo apt-get update
sudo apt-get install -y wget
npm install -g ghost-static-site-generator

- name: Prepare Ghost content and blog folder
env:
CONTENT_PATH: ${{ inputs.content_path || 'content' }}
ALLOW_EMPTY: ${{ inputs.allow_empty }}
run: |
set -euo pipefail
WORKSPACE="${GITHUB_WORKSPACE}"
export GHOST_INSTALL="${WORKSPACE}/.gogp-home"
mkdir -p "${GHOST_INSTALL}"
CONTENT_SRC="${WORKSPACE}/blog/${CONTENT_PATH}"
if [ -d "$CONTENT_SRC" ]; then
export GHOST_CONTENT="$CONTENT_SRC"
elif [ "${ALLOW_EMPTY}" = "true" ]; then
export GHOST_CONTENT="${GHOST_INSTALL}/content"
mkdir -p "$GHOST_CONTENT"
echo "No ${CONTENT_PATH}/ in the repository; using an empty Ghost content directory."
else
echo "[ERROR] ${CONTENT_PATH}/ was not found in the repository." >&2
echo "[ERROR] Refusing to publish an empty Ghost site. Add a content snapshot or set allow_empty: true." >&2
exit 1
fi
echo "GHOST_INSTALL=$GHOST_INSTALL" >> "$GITHUB_ENV"
echo "GHOST_CONTENT=$GHOST_CONTENT" >> "$GITHUB_ENV"
bash "${WORKSPACE}/gogp/scripts/compose-setup.sh"

- name: Start Ghost
env:
GHOST_PORT: ${{ inputs.ghost_port || '2373' }}
GHOST_URL: http://localhost:${{ inputs.ghost_port || '2373' }}
run: |
set -euo pipefail
docker compose -f "${GITHUB_WORKSPACE}/gogp/compose.yaml" up -d
bash -c 'set -euo pipefail; source "${GITHUB_WORKSPACE}/gogp/includes/lib/common.sh"; wait_for_ghost_http 45'

- name: Export static site
env:
GHOST_PORT: ${{ inputs.ghost_port || '2373' }}
GH_USERNAME: ${{ inputs.gh_username }}
GH_REPO: ${{ inputs.gh_repo }}
PRODUCTION_DOMAIN: ${{ inputs.production_domain }}
run: |
set -euo pipefail
export GHOST_SERVER_URL="http://localhost:${GHOST_PORT}"
bash "${GITHUB_WORKSPACE}/gogp/scripts/export-static.sh"

- name: Stop Ghost
if: always()
run: docker compose -f "${GITHUB_WORKSPACE}/gogp/compose.yaml" down --remove-orphans || true

- name: Setup GitHub Pages
if: ${{ inputs.deploy_pages == true || inputs.deploy_pages == 'true' }}
uses: actions/configure-pages@v5

- name: Upload GitHub Pages artifact
if: ${{ inputs.deploy_pages == true || inputs.deploy_pages == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ${{ github.workspace }}/.gogp-home/publish

deploy:
if: ${{ inputs.deploy_pages == true || inputs.deploy_pages == 'true' }}
needs: export
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,7 @@ GitHub.sublime-settings

# Track shell helpers (overrides Python lib/ ignore above)
!includes/lib/
!includes/lib/**
!includes/lib/**

# Local Compose scratch (CI smoke / docker volumes)
.tmp-ghost-content/
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project are documented here.

## [3.1.0] - 2026-11-16

### Fixed

- Static publishing no longer stops when `wget` saves an HTTP error page (status 8), including Ghost's 404 page. That exit used to abort `gssg` before it rewrote localhost links.
- `gssg` is now called with `--url`, the flag that rewrites localhost links. gssg 1.1.4 ignores `--productionDomain`.
- Markdown indexes written by Ghost 6 get the same public URL rewrite, so validation no longer fails on those files.

### Added

- **Docker Compose** alternative to `install.sh` using the official `ghost:6` image, SQLite at `~/.ghost/content/data/ghost.db`, and a bind mount at `~/.ghost/content` ([#28](https://github.com/paladini/ghost-on-github-pages/issues/28))
- `scripts/compose-setup.sh`, `scripts/export-static.sh`, and `scripts/compose-smoke.sh`
- Reusable GitHub Action to generate static files in CI and publish to GitHub Pages
- Guides: [docs/v3/DOCKER.md](docs/v3/DOCKER.md), [docs/v3/CI.md](docs/v3/CI.md)

## [3.0.0] - 2026-07-03

### Added
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,35 @@ CI runs the same checks on every pull request. Run them before submitting:
```bash
bash scripts/shellcheck.sh
bash tests/run-validation-tests.sh
bash tests/run-compose-tests.sh
```

- **shellcheck** — catches common mistakes in shell scripts (`install.sh`, `deploy.sh`, `migrate.sh`, and related files).
- **Validation tests** — verify that published HTML does not contain broken `localhost` links or image paths. These tests protect users from bugs that only show up after publishing.
- **Compose tests** — check `compose.yaml` and the publish GitHub Action against the documented Ghost 6 / `~/.ghost` layout. If Docker is installed, also run `bash scripts/compose-smoke.sh` (add `--start` to boot the image).

If you do not have `shellcheck` installed, the script skips that step with a warning. On Ubuntu/Debian: `sudo apt-get install shellcheck`.

### Pull request checklist

- [ ] `bash scripts/shellcheck.sh` passes (or only warns that shellcheck is missing)
- [ ] `bash tests/run-validation-tests.sh` passes
- [ ] `bash tests/run-compose-tests.sh` passes
- [ ] Documentation updated if behavior or user-facing steps changed
- [ ] Commit message explains **why** the change helps users

### Where to look in the codebase

| Area | Purpose |
|------|---------|
| `install.sh` | First-time setup |
| `install.sh` | First-time setup (Ghost-CLI) |
| `compose.yaml` / `scripts/compose-setup.sh` | Optional Docker Compose setup |
| `migrate.sh` | Upgrade from Classic v2 to v3 |
| `includes/deploy.sh` | Publish blog to GitHub Pages |
| `includes/lib/common.sh` | Shared helpers |
| `scripts/validate-static.sh` | Pre-publish HTML checks |
| `scripts/export-static.sh` | Static export without `git push` (host or CI) |
| `.github/workflows/publish-static.yml` | Reusable Pages publish Action |
| `docs/` | User-facing guides |

## Questions?
Expand Down
30 changes: 30 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Official Ghost image for local editing. Static export still uses gssg (host or CI).
# See docs/v3/DOCKER.md

# Fixed project name so `docker compose up/down` is the same stack from this
# repository and from ~/.ghost.
name: gogp

services:
ghost:
image: ghost:6
ports:
- "${GHOST_PORT:-2373}:2368"
environment:
NODE_ENV: development
url: ${GHOST_URL:-http://localhost:2373}
database__client: sqlite3
database__connection__filename: /var/lib/ghost/content/data/ghost.db
volumes:
- ${GHOST_CONTENT:-${HOME}/.ghost/content}:/var/lib/ghost/content
healthcheck:
test:
[
"CMD-SHELL",
"node -e \"require('http').get('http://127.0.0.1:2368', r => process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1)).on('error', () => process.exit(1))\"",
]
interval: 10s
timeout: 5s
retries: 12
start_period: 40s
restart: unless-stopped
6 changes: 5 additions & 1 deletion docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ Short definitions for words used in this project.

**wget** — A small program used behind the scenes to copy web pages when building your static site. The install guide helps you install it if needed.

**Node.js (Node)** — Software Ghost needs to run. You install it once before using this project.
**Node.js (Node)** — Software Ghost needs to run (and that `gssg` uses when publishing). You install it once before using this project, even if Ghost itself runs in Docker.

**Docker Compose** — A way to run Ghost in a container using the official `ghost:6` image, with your files in `~/.ghost/content`. See [v3/DOCKER.md](v3/DOCKER.md).

**GitHub Action** — A script GitHub runs for you. This project can generate the static blog in CI and publish it to GitHub Pages. See [v3/CI.md](v3/CI.md).
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Pick the guide that matches your situation.
- [What to install first](v3/REQUIREMENTS.md)
- [Getting started — new blog](v3/GETTING-STARTED.md)
- [How to publish changes](v3/DEPLOY.md)
- [Run Ghost with Docker Compose](v3/DOCKER.md)
- [Publish from GitHub Actions](v3/CI.md)
- [Multiple GitHub repositories (optional)](v3/MULTI-REPO.md)

## Classic version 2.x (maintenance)
Expand Down
26 changes: 26 additions & 0 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ Answers in plain English. If you are stuck, [open an issue](https://github.com/p
2. Make sure you have an internet connection.
3. On Linux, you may need `curl` and build tools for Ghost — see Ghost's official docs.

## Docker Compose

### `docker compose` is not found

Install Docker Desktop (Windows/macOS) or Docker Engine + the Compose plugin (Linux). In WSL, enable the Docker Desktop WSL integration. See [DOCKER.md](v3/DOCKER.md).

### Ghost never opens at http://localhost:2373

1. Run `docker compose ps` and `docker compose logs ghost`.
2. Confirm nothing else is using port **2373**.
3. If you set `GHOST_PORT`, also set `GHOST_URL` to `http://localhost:THAT_PORT`.

### Posts disappear after `docker compose down`

The database must be `~/.ghost/content/data/ghost.db`. If that file is missing, the container was not using the Compose file from this project. Run `./scripts/compose-setup.sh` again and start Ghost with `docker compose up -d` so the project name is `gogp`.

### `uninstall.sh` says the stack may still be running

Docker could not stop the `gogp` project. Run `docker compose ps` in `~/.ghost` and then `docker compose down`. Your files are still in `~/.ghost` until you delete that folder yourself.

### `deploy.sh` says the blog folder is not set up

Run `./scripts/compose-setup.sh` from this project first so `~/.ghost/.docker` and `deploy.sh` exist. Do not mix a Ghost-CLI install and Compose in the same `~/.ghost` folder.

## Publish problems

### "Static files were not created"
Expand All @@ -35,6 +59,8 @@ Answers in plain English. If you are stuck, [open an issue](https://github.com/p
ghost start
```

Or, with Docker: `docker compose up -d` (see [DOCKER.md](v3/DOCKER.md)).

2. Open `http://localhost:2373` in your browser and confirm the blog loads.
3. Run `./deploy.sh` again.

Expand Down
Loading
Loading