|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-deploy: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: '3.13' |
| 28 | + |
| 29 | + - name: Cache dependencies |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: ~/.cache/pip |
| 33 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} |
| 34 | + restore-keys: | |
| 35 | + ${{ runner.os }}-pip- |
| 36 | +
|
| 37 | + - name: Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install mkdocs mkdocstrings[python] pymdown-extensions |
| 41 | +
|
| 42 | + - name: Build documentation (PR test) |
| 43 | + if: github.event_name == 'pull_request' |
| 44 | + run: | |
| 45 | + mkdocs build --clean --strict --verbose |
| 46 | + echo "📚 Documentation build successful for PR!" |
| 47 | +
|
| 48 | + - name: Comment on PR |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + uses: actions/github-script@v7 |
| 51 | + with: |
| 52 | + script: | |
| 53 | + github.rest.issues.createComment({ |
| 54 | + issue_number: context.issue.number, |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + body: '📚 Documentation build **successful**! ✅\n\n' + |
| 58 | + '🔍 Changes validated:\n' + |
| 59 | + '- MkDocs build completed without errors\n' + |
| 60 | + '- All links and references checked\n' + |
| 61 | + '- ReadTheDocs theme applied\n\n' + |
| 62 | + '💡 Ready to merge for deployment!' |
| 63 | + }) |
| 64 | +
|
| 65 | + - name: Configure Git for deployment |
| 66 | + if: github.ref == 'refs/heads/main' |
| 67 | + run: | |
| 68 | + git config --global user.name "github-actions[bot]" |
| 69 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 70 | +
|
| 71 | + - name: Deploy to GitHub Pages |
| 72 | + if: github.ref == 'refs/heads/main' |
| 73 | + run: | |
| 74 | + mkdocs gh-deploy --force |
0 commit comments