name: Publish documentation on: push: branches: - master workflow_dispatch: jobs: update-cli-screenshots: if: ${{ github.repository == 'commitizen-tools/commitizen' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 - name: Set up Python uses: astral-sh/setup-uv@v7 - name: Set up Go uses: actions/setup-go@v7 with: go-version: '1.25.8' - name: Set up VHS run: | sudo apt update sudo apt install -y ffmpeg ttyd # Pin VHS to a known version so gif rendering is deterministic across runs. # Bump this version intentionally when you want to refresh all interactive screenshots. go install github.com/charmbracelet/vhs@v0.11.0 - name: Install dependencies run: | uv --version uv sync --frozen --group base --group script - name: Update CLI screenshots run: | uv run --no-sync poe doc:screenshots - name: Discard cli_interactive regeneration when render inputs are unchanged # VHS gif output drifts by a few bytes between runs even when sources are # identical, which used to produce a noisy stream of `docs(cli/screenshots)` # commits. Keep regenerated gifs only when something that can actually # change the rendered content has changed in this push (the tape sources, # or any commitizen source code the tapes execute), or when manually # dispatched. run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "Manual run; keeping any regenerated cli_interactive gifs." exit 0 fi before="${{ github.event.before }}" if [[ -z "$before" || "$before" == "0000000000000000000000000000000000000000" ]]; then echo "No previous SHA available (first push or new branch); keeping any regenerated cli_interactive gifs." exit 0 fi if ! git rev-parse --verify "$before^{commit}" >/dev/null 2>&1; then echo "Previous SHA $before is unreachable; keeping any regenerated cli_interactive gifs." exit 0 fi if git diff --quiet "$before" HEAD -- docs/images/'*.tape' docs/images/shared/ commitizen/; then echo "Tape sources and commitizen/ unchanged since $before; discarding cli_interactive gif regeneration to avoid byte-level churn." git checkout -- docs/images/cli_interactive/ else echo "Render inputs changed since $before (tapes or commitizen/); keeping regenerated cli_interactive gifs." fi - name: Commit and push updated CLI screenshots run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add docs/images/cli_help docs/images/cli_interactive if [[ -n "$(git status --porcelain)" ]]; then git commit -m "docs(cli/screenshots): update CLI screenshots" -m "[skip ci]" git pull --rebase origin master git push else echo "No changes to commit. Skipping." fi publish-documentation: if: ${{ github.repository == 'commitizen-tools/commitizen' }} runs-on: ubuntu-latest needs: update-cli-screenshots steps: - uses: actions/checkout@v7 with: token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" fetch-depth: 0 - name: Pull latest changes run: | git pull origin master - name: Set up Python uses: astral-sh/setup-uv@v7 - name: Install dependencies run: | uv --version uv sync --frozen --only-group base --only-group documentation - name: Generate Sponsors 💖 uses: JamesIves/github-sponsors-readme-action@v1 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_ORG }} file: "docs/README.md" organization: true - name: Build docs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | uv run --no-sync poe doc:build - name: Deploy 🚀 uses: JamesIves/github-pages-deploy-action@v4 with: folder: ./site # The folder the action should deploy. branch: gh-pages