GitHub Action Setup
If you have an existing Antora UI theme, you can add our GitHub Action to enable automatic preview generation.
Prerequisites
Your repository should already have:
-
A valid Antora UI theme structure
-
package.jsonwith build scripts -
gulpfile.jsfor bundling
Adding Sample Content
Create a docs/ folder with sample Antora content. This content will be used to generate your preview site.
Minimal Structure
docs/
├── antora.yml
└── modules/
└── ROOT/
├── nav.adoc
└── pages/
├── index.adoc
└── examples.adoc
Sample Content Tips
Include examples of all UI elements your theme supports:
-
Headings (all levels)
-
Code blocks (multiple languages)
-
Tables (simple and complex)
-
Admonitions (NOTE, TIP, WARNING, CAUTION, IMPORTANT)
-
Lists (ordered, unordered, nested)
-
Images
-
Links (internal and external)
-
Sidebar navigation (multiple levels)
Adding the Playbook
Create antora-playbook.yml in your repository root:
site:
title: My Theme Preview
start_page: preview::index.adoc
content:
sources:
- url: .
start_path: docs
ui:
bundle:
url: ./build/ui-bundle.zip
snapshot: true
output:
dir: ./build/site
Adding the GitHub Action
Create .github/workflows/preview.yml:
name: Build Preview
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build UI bundle
run: npx gulp bundle
- name: Install Antora
run: npm install @antora/cli @antora/site-generator
- name: Build preview site
run: npx antora antora-playbook.yml
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/site
- name: Wait for deployment
run: sleep 30
- name: Generate preview screenshot
uses: simonw/shot-scraper-action@v1
with:
url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/
output: preview.png
width: 1280
height: 720
- name: Commit screenshot
run: |
git config user.name "Preview Bot"
git config user.email "actions@github.com"
git add preview.png
git commit -m "Update preview screenshot" || exit 0
git push
Enable GitHub Pages
-
Go to your repository Settings
-
Navigate to Pages
-
Set Source to GitHub Actions
-
Save
Trigger the Build
Push your changes to trigger the action:
git add .
git commit -m "Add preview generation"
git push
Verify
After the action completes:
-
Check that
preview.pngexists in your repository -
Visit
https://{username}.github.io/{repo-name}/to see your preview site
Troubleshooting
Screenshot is blank or wrong
The screenshot is taken 30 seconds after deployment. If your site takes longer to propagate:
- name: Wait for deployment
run: sleep 60 # Increase wait time