|
1 | 1 | name: Build Documentation |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - 'dev/mkdocs.yml' |
| 9 | + - '.readthedocs.yaml' |
| 10 | + - 'dev/requirements-rtd.txt' |
| 11 | + - 'ccbt/**' |
| 12 | + pull_request: |
| 13 | + branches: [main] |
| 14 | + paths: |
| 15 | + - 'docs/**' |
| 16 | + - 'dev/mkdocs.yml' |
| 17 | + - '.readthedocs.yaml' |
| 18 | + - 'dev/requirements-rtd.txt' |
4 | 19 | workflow_dispatch: |
5 | 20 | # Can be triggered manually from any branch for testing |
6 | 21 | # Documentation is automatically published to Read the Docs when changes are pushed |
@@ -94,16 +109,13 @@ jobs: |
94 | 109 | |
95 | 110 | - name: Generate coverage report |
96 | 111 | run: | |
97 | | - uv run pytest -c dev/pytest.ini tests/ --cov=ccbt --cov-report=html:site/reports/htmlcov || echo "⚠️ Coverage report generation failed, continuing..." |
| 112 | + uv run pytest -c dev/pytest.ini tests/ --cov=ccbt --cov-report=html:site/reports/htmlcov |
98 | 113 | continue-on-error: true |
99 | 114 |
|
100 | | - - name: Generate Bandit reports |
| 115 | + - name: Generate Bandit report |
101 | 116 | run: | |
102 | 117 | uv run python tests/scripts/ensure_bandit_dir.py |
103 | | - # Generate main bandit report |
104 | | - uv run bandit -r ccbt/ -f json -o docs/reports/bandit/bandit-report.json --severity-level medium -x tests,benchmarks,dev,dist,docs,htmlcov,site,.venv,.pre-commit-cache,.pre-commit-home,.pytest_cache,.ruff_cache,.hypothesis,.github,.ccbt,.cursor,.benchmarks || echo "⚠️ Bandit report generation failed" |
105 | | - # Generate all severity levels report |
106 | | - uv run bandit -r ccbt/ -f json -o docs/reports/bandit/bandit-report-all.json --severity-level all -x tests,benchmarks,dev,dist,docs,htmlcov,site,.venv,.pre-commit-cache,.pre-commit-home,.pytest_cache,.ruff_cache,.hypothesis,.github,.ccbt,.cursor,.benchmarks || echo "⚠️ Bandit all report generation failed" |
| 118 | + uv run bandit -r ccbt/ -f json -o docs/reports/bandit/bandit-report.json --severity-level medium -x tests,benchmarks,dev,dist,docs,htmlcov,site,.venv,.pre-commit-cache,.pre-commit-home,.pytest_cache,.ruff_cache,.hypothesis,.github,.ccbt,.cursor,.benchmarks |
107 | 119 | continue-on-error: true |
108 | 120 |
|
109 | 121 | - name: Ensure report files exist in documentation location |
@@ -162,6 +174,34 @@ jobs: |
162 | 174 | path: site/ |
163 | 175 | retention-days: 7 |
164 | 176 |
|
| 177 | + - name: Trigger Read the Docs build |
| 178 | + if: env.RTD_API_TOKEN != '' |
| 179 | + env: |
| 180 | + RTD_API_TOKEN: ${{ secrets.RTD_API_TOKEN }} |
| 181 | + RTD_PROJECT_SLUG: ${{ secrets.RTD_PROJECT_SLUG || 'ccbittorrent' }} |
| 182 | + BRANCH_NAME: ${{ github.ref_name }} |
| 183 | + run: | |
| 184 | + echo "Triggering Read the Docs build for branch: $BRANCH_NAME" |
| 185 | + curl -X POST \ |
| 186 | + -H "Authorization: Token $RTD_API_TOKEN" \ |
| 187 | + -H "Content-Type: application/json" \ |
| 188 | + "https://readthedocs.org/api/v3/projects/$RTD_PROJECT_SLUG/versions/$BRANCH_NAME/builds/" \ |
| 189 | + -d "{}" || echo "⚠️ Failed to trigger Read the Docs build. This may be expected if the branch is not configured in Read the Docs." |
| 190 | + continue-on-error: true |
| 191 | + |
| 192 | + - name: Read the Docs build info |
| 193 | + if: env.RTD_API_TOKEN == '' |
| 194 | + run: | |
| 195 | + echo "ℹ️ Read the Docs API token not configured." |
| 196 | + echo " To enable automatic Read the Docs builds from any branch:" |
| 197 | + echo " 1. Get your Read the Docs API token from https://readthedocs.org/accounts/token/" |
| 198 | + echo " 2. Add it as a GitHub secret named RTD_API_TOKEN" |
| 199 | + echo " 3. Optionally set RTD_PROJECT_SLUG secret (defaults to 'ccbittorrent')" |
| 200 | + echo "" |
| 201 | + echo " Note: Read the Docs will only build branches configured in your project settings." |
| 202 | + echo " By default, only 'main' and 'dev' branches are built automatically." |
| 203 | + |
165 | 204 | # Note: Documentation is automatically published to Read the Docs |
166 | | - # when changes are pushed to the repository. No GitHub Pages deployment needed. |
| 205 | + # when changes are pushed to the repository for configured branches (main/dev by default). |
| 206 | + # To build other branches, configure them in Read the Docs project settings or use the API trigger above. |
167 | 207 |
|
0 commit comments