Skip to content

fix(docs): add collection index pages, fix Jekyll build errors, and apply modern theme #173

fix(docs): add collection index pages, fix Jekyll build errors, and apply modern theme

fix(docs): add collection index pages, fix Jekyll build errors, and apply modern theme #173

Workflow file for this run

name: Build and deploy Jekyll site to GitHub Pages
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
outputs:
pages_enabled: ${{ steps.pages.outcome == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 0 # Increment this number if you need to re-download cached gems
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
continue-on-error: true
- name: Debug Pages outputs
if: always()
run: |
echo "pages.outcome=${{ steps.pages.outcome }}"
echo "pages.base_path=${{ steps.pages.outputs.base_path }}"
- name: Check Pages Status
if: steps.pages.outcome == 'failure'
run: |
echo "⚠️ GitHub Pages is not enabled for this repository."
echo "📖 To enable GitHub Pages:"
echo " 1. Go to repository Settings"
echo " 2. Navigate to 'Pages' in the sidebar"
echo " 3. Under 'Source', select 'GitHub Actions'"
echo " 4. Save the settings"
echo " 5. Re-run this workflow"
echo ""
echo "💡 This workflow will build the site but skip deployment until Pages is enabled."
- name: Build with Jekyll
# Outputs to the './_site' directory by default
# Save full build log to jekyll_build.log for debugging and upload as artifact later
run: |
set -o pipefail
if [[ "${{ steps.pages.outcome }}" == "success" ]]; then
bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" 2>&1 | tee jekyll_build.log
echo "EXIT_CODE=${PIPESTATUS[0]}" >> jekyll_build.log || true
else
bundle exec jekyll build 2>&1 | tee jekyll_build.log
echo "EXIT_CODE=${PIPESTATUS[0]}" >> jekyll_build.log || true
fi
env:
JEKYLL_ENV: production
- name: Upload site artifact (Pages)
# Upload Pages artifact when Pages is configured
if: steps.pages.outcome == 'success'
uses: actions/upload-pages-artifact@v4
- name: Upload site artifact for preview
# If Pages is not configured, still upload as regular artifact for review
if: steps.pages.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: github-pages
path: _site/
retention-days: 1
- name: Upload Jekyll build log
if: always()
uses: actions/upload-artifact@v4
with:
name: jekyll-build-log
path: jekyll_build.log
retention-days: 7
# Deployment job
deploy:
# Only deploy if Pages is configured and we're on main branch
if: github.ref == 'refs/heads/main' && needs.build.outputs.pages_enabled == 'true'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
outputs:
page_url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
test-pages:
# Run tests after successful deploy
if: needs.deploy.outputs.page_url != ''
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
- name: Install dependencies
run: |
# Use npm ci when a lockfile exists for reproducible installs, otherwise fall back to npm install
if [ -f package-lock.json ]; then
echo "Found package-lock.json, running npm ci"
npm ci
else
echo "No package-lock.json found, running npm install"
npm install
fi
- name: Install Playwright browsers
run: |
npx playwright install --with-deps
- name: Wait for site to be reachable
env:
PAGE_URL: ${{ needs.deploy.outputs.page_url }}
run: |
set -e
echo "Waiting for $PAGE_URL ..."
for i in {1..30}; do
status=$(curl -s -o /dev/null -w "%{http_code}" "$PAGE_URL" || echo "000")
if [ "$status" = "200" ]; then
echo "Site is up"
exit 0
fi
echo "Attempt $i: HTTP $status - sleeping 5s"
sleep 5
done
echo "Site did not become reachable in time"
exit 1
- name: Run Playwright tests
env:
PAGE_URL: ${{ needs.deploy.outputs.page_url }}
run: |
npm test --silent