name: Deploy main to GitHub Pages (stable) on: push: branches: [main] workflow_dispatch: permissions: contents: write jobs: deploy-main-pages: if: ${{ env.ENABLE_DEPLOY == 'true' && env.ACT != 'true' }} runs-on: ubuntu-latest steps: - name: Checkout (main) uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.13" cache: "pip" cache-dependency-path: mkdocs/requirements.txt - name: Install dependencies run: | set -euo pipefail pip install -r mkdocs/requirements.txt - name: Build (MKDOCS_STRICT) run: | set -euo pipefail MKDOCS_STRICT="${MKDOCS_STRICT:-true}" STRICT_FLAG="" if [ "${MKDOCS_STRICT}" = "true" ]; then STRICT_FLAG="--strict" fi OFFLINE=true mkdocs build ${STRICT_FLAG} -f mkdocs/mkdocs.yml -d site_build - name: Checkout gh-pages branch run: | set -euo pipefail git fetch origin gh-pages:gh-pages || true if git show-ref --verify --quiet refs/heads/gh-pages; then git switch gh-pages else git switch --orphan gh-pages rm -rf ./* git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit --allow-empty -m "Initialize gh-pages" fi - name: Publish stable site to root (preserve rc/) run: | set -euo pipefail mkdir -p _keep if [ -d rc ]; then cp -a rc _keep/; fi rm -rf ./* if [ -d _keep/rc ]; then mv _keep/rc ./rc; fi rm -rf _keep cp -a ../site_build/. . git add -A git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m "Deploy stable site from main" || echo "No changes to commit" git push origin gh-pages