name: Deploy docs to GitHub Pages # Build the MkDocs Material site and publish to GitHub Pages on every push # to main. Also deployable on demand via the workflow_dispatch trigger. on: push: branches: - main paths: - "docs/**" - "mkdocs.yml" - "requirements-docs.txt" - ".github/workflows/docs.yml" workflow_dispatch: env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" permissions: contents: read # Allow only one concurrent deploy; cancel in-progress runs on a new push. concurrency: group: "pages" cancel-in-progress: true jobs: build-and-publish: name: Build and publish site runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 # Required by mkdocs git-revision plugins if added. - name: Set up Python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.11" cache: "pip" cache-dependency-path: requirements-docs.txt - name: Install docs dependencies run: | python -m pip install --upgrade pip python -m pip install -r requirements-docs.txt python -m pip install -e ".[dev]" - name: Validate public docs tracker run: | python -m pytest -q --no-cov \ src/tests/test_bug_smoke_tracker.py \ src/tests/test_feature_user_story_tracker.py \ src/tests/test_dashboard_user_story_tracker.py \ src/tests/test_toolbox_cli.py - name: Build site (strict) run: | python -m mkdocs build --strict - name: Publish site to gh-pages env: CTX_PAGES_DEPLOY_KEY: ${{ secrets.CTX_PAGES_DEPLOY_KEY }} run: | set -euo pipefail if [ -z "${CTX_PAGES_DEPLOY_KEY}" ]; then echo "::error::CTX_PAGES_DEPLOY_KEY secret is required for Pages branch publishing." exit 1 fi git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" install -m 700 -d "${HOME}/.ssh" printf '%s\n' "${CTX_PAGES_DEPLOY_KEY}" > "${HOME}/.ssh/ctx_pages_deploy_key" chmod 600 "${HOME}/.ssh/ctx_pages_deploy_key" ssh-keyscan github.com >> "${HOME}/.ssh/known_hosts" export GIT_SSH_COMMAND="ssh -i ${HOME}/.ssh/ctx_pages_deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" trap 'rm -f "${HOME}/.ssh/ctx_pages_deploy_key"' EXIT publish_dir="${RUNNER_TEMP}/ctx-gh-pages" rm -rf "${publish_dir}" git init "${publish_dir}" cd "${publish_dir}" git remote add origin "git@github.com:${GITHUB_REPOSITORY}.git" if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then git fetch --depth 1 origin gh-pages git checkout -B gh-pages origin/gh-pages else git checkout --orphan gh-pages fi find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + cp -a "${GITHUB_WORKSPACE}/site/." . touch .nojekyll git add -A if git diff --cached --quiet; then echo "No documentation changes to publish." exit 0 fi git commit -m "Deploy docs for ${GITHUB_SHA}" git push --force origin gh-pages