|
| 1 | +name: Deploy MkDocs to Netlify |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-and-deploy: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v6 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Python |
| 23 | + uses: actions/setup-python@v6 |
| 24 | + with: |
| 25 | + python-version: 'latest' |
| 26 | + cache: pip |
| 27 | + cache-dependency-path: requirements-docs.txt |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: pip install -r requirements-docs.txt |
| 31 | + |
| 32 | + - name: Generate MkDocs site |
| 33 | + run: | |
| 34 | + bash scripts/build_site.sh |
| 35 | + mkdocs build |
| 36 | + env: |
| 37 | + GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }} |
| 38 | + |
| 39 | + - name: Setup Node.js (for Netlify CLI) |
| 40 | + uses: actions/setup-node@v6 |
| 41 | + with: |
| 42 | + node-version: lts/* |
| 43 | + |
| 44 | + - name: Install Netlify CLI |
| 45 | + run: npm install -g netlify-cli |
| 46 | + |
| 47 | + # Deploy preview for Pull Requests |
| 48 | + - name: Deploy preview to Netlify |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + run: netlify deploy --dir=site --message="PR ${{ github.event.number }} - Run ${{ github.run_number }}" |
| 51 | + env: |
| 52 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 53 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 54 | + |
| 55 | + # Deploy to Production for Main branch pushes |
| 56 | + - name: Deploy to Netlify Production |
| 57 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 58 | + run: netlify deploy --prod --dir=site --message="Deploy Main - Run ${{ github.run_number }}" |
| 59 | + env: |
| 60 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 61 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
0 commit comments