| 1 |
name: Publish documentation |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
workflow_dispatch: |
| 8 |
|
| 9 |
jobs: |
| 10 |
update-cli-screenshots: |
| 11 |
if: ${{ github.repository == 'commitizen-tools/commitizen' }} |
| 12 |
runs-on: ubuntu-latest |
| 13 |
steps: |
| 14 |
- uses: actions/checkout@v7 |
| 15 |
with: |
| 16 |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 17 |
fetch-depth: 0 |
| 18 |
- name: Set up Python |
| 19 |
uses: astral-sh/setup-uv@v7 |
| 20 |
- name: Set up Go |
| 21 |
uses: actions/setup-go@v7 |
| 22 |
with: |
| 23 |
go-version: '1.25.8' |
| 24 |
- name: Set up VHS |
| 25 |
run: | |
| 26 |
sudo apt update |
| 27 |
sudo apt install -y ffmpeg ttyd |
| 28 |
# Pin VHS to a known version so gif rendering is deterministic across runs. |
| 29 |
# Bump this version intentionally when you want to refresh all interactive screenshots. |
| 30 |
go install github.com/charmbracelet/[email protected] |
| 31 |
- name: Install dependencies |
| 32 |
run: | |
| 33 |
uv --version |
| 34 |
uv sync --frozen --group base --group script |
| 35 |
- name: Update CLI screenshots |
| 36 |
run: | |
| 37 |
uv run --no-sync poe doc:screenshots |
| 38 |
- name: Discard cli_interactive regeneration when render inputs are unchanged |
| 39 |
# VHS gif output drifts by a few bytes between runs even when sources are |
| 40 |
# identical, which used to produce a noisy stream of `docs(cli/screenshots)` |
| 41 |
# commits. Keep regenerated gifs only when something that can actually |
| 42 |
# change the rendered content has changed in this push (the tape sources, |
| 43 |
# or any commitizen source code the tapes execute), or when manually |
| 44 |
# dispatched. |
| 45 |
run: | |
| 46 |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 47 |
echo "Manual run; keeping any regenerated cli_interactive gifs." |
| 48 |
exit 0 |
| 49 |
fi |
| 50 |
before="${{ github.event.before }}" |
| 51 |
if [[ -z "$before" || "$before" == "0000000000000000000000000000000000000000" ]]; then |
| 52 |
echo "No previous SHA available (first push or new branch); keeping any regenerated cli_interactive gifs." |
| 53 |
exit 0 |
| 54 |
fi |
| 55 |
if ! git rev-parse --verify "$before^{commit}" >/dev/null 2>&1; then |
| 56 |
echo "Previous SHA $before is unreachable; keeping any regenerated cli_interactive gifs." |
| 57 |
exit 0 |
| 58 |
fi |
| 59 |
if git diff --quiet "$before" HEAD -- docs/images/'*.tape' docs/images/shared/ commitizen/; then |
| 60 |
echo "Tape sources and commitizen/ unchanged since $before; discarding cli_interactive gif regeneration to avoid byte-level churn." |
| 61 |
git checkout -- docs/images/cli_interactive/ |
| 62 |
else |
| 63 |
echo "Render inputs changed since $before (tapes or commitizen/); keeping regenerated cli_interactive gifs." |
| 64 |
fi |
| 65 |
- name: Commit and push updated CLI screenshots |
| 66 |
run: | |
| 67 |
git config --global user.name "github-actions[bot]" |
| 68 |
git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 69 |
git add docs/images/cli_help docs/images/cli_interactive |
| 70 |
|
| 71 |
if [[ -n "$(git status --porcelain)" ]]; then |
| 72 |
git commit -m "docs(cli/screenshots): update CLI screenshots" -m "[skip ci]" |
| 73 |
git pull --rebase origin master |
| 74 |
git push |
| 75 |
else |
| 76 |
echo "No changes to commit. Skipping." |
| 77 |
fi |
| 78 |
|
| 79 |
publish-documentation: |
| 80 |
if: ${{ github.repository == 'commitizen-tools/commitizen' }} |
| 81 |
runs-on: ubuntu-latest |
| 82 |
needs: update-cli-screenshots |
| 83 |
steps: |
| 84 |
- uses: actions/checkout@v7 |
| 85 |
with: |
| 86 |
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" |
| 87 |
fetch-depth: 0 |
| 88 |
- name: Pull latest changes |
| 89 |
run: | |
| 90 |
git pull origin master |
| 91 |
- name: Set up Python |
| 92 |
uses: astral-sh/setup-uv@v7 |
| 93 |
- name: Install dependencies |
| 94 |
run: | |
| 95 |
uv --version |
| 96 |
uv sync --frozen --only-group base --only-group documentation |
| 97 |
- name: Generate Sponsors 💖 |
| 98 |
uses: JamesIves/github-sponsors-readme-action@v1 |
| 99 |
with: |
| 100 |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_ORG }} |
| 101 |
file: "docs/README.md" |
| 102 |
organization: true |
| 103 |
- name: Build docs |
| 104 |
env: |
| 105 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 |
run: | |
| 107 |
uv run --no-sync poe doc:build |
| 108 |
- name: Deploy 🚀 |
| 109 |
uses: JamesIves/github-pages-deploy-action@v4 |
| 110 |
with: |
| 111 |
folder: ./site # The folder the action should deploy. |
| 112 |
branch: gh-pages |