|
| 1 | +name: docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - init |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + id-token: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + environment: docs |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python-version: ['3.14'] |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v6 |
| 22 | + |
| 23 | + - name: Filter changed file paths to outputs |
| 24 | + |
| 25 | + id: changes |
| 26 | + with: |
| 27 | + filters: | |
| 28 | + root_docs: |
| 29 | + - CHANGES |
| 30 | + - README.* |
| 31 | + docs: |
| 32 | + - 'docs/**' |
| 33 | + - 'examples/**' |
| 34 | + python_files: |
| 35 | + - 'src/gp_sphinx/**/*.py' |
| 36 | + - pyproject.toml |
| 37 | + - uv.lock |
| 38 | +
|
| 39 | + - name: Should publish |
| 40 | + # if: steps.changes.outputs.docs == 'true' || steps.changes.outputs.root_docs == 'true' || steps.changes.outputs.python_files == 'true' |
| 41 | + run: echo "PUBLISH=$(echo true)" >> $GITHUB_ENV |
| 42 | + |
| 43 | + - name: Install uv |
| 44 | + uses: astral-sh/setup-uv@v7 |
| 45 | + if: env.PUBLISH == 'true' |
| 46 | + with: |
| 47 | + enable-cache: true |
| 48 | + |
| 49 | + - name: Set up Python ${{ matrix.python-version }} |
| 50 | + if: env.PUBLISH == 'true' |
| 51 | + run: uv python install ${{ matrix.python-version }} |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + if: env.PUBLISH == 'true' |
| 55 | + run: uv sync --all-extras --dev |
| 56 | + |
| 57 | + - name: Install just |
| 58 | + if: env.PUBLISH == 'true' |
| 59 | + uses: extractions/setup-just@v3 |
| 60 | + |
| 61 | + - name: Print python versions |
| 62 | + if: env.PUBLISH == 'true' |
| 63 | + run: | |
| 64 | + python -V |
| 65 | + uv run python -V |
| 66 | +
|
| 67 | + - name: Cache sphinx fonts |
| 68 | + if: env.PUBLISH == 'true' |
| 69 | + uses: actions/cache@v5 |
| 70 | + with: |
| 71 | + path: ~/.cache/sphinx-fonts |
| 72 | + key: sphinx-fonts-${{ hashFiles('docs/conf.py') }} |
| 73 | + restore-keys: | |
| 74 | + sphinx-fonts- |
| 75 | +
|
| 76 | + - name: Build documentation |
| 77 | + if: env.PUBLISH == 'true' |
| 78 | + run: | |
| 79 | + cd docs && just html |
| 80 | +
|
| 81 | + - name: Configure AWS Credentials |
| 82 | + if: env.PUBLISH == 'true' |
| 83 | + uses: aws-actions/configure-aws-credentials@v5 |
| 84 | + with: |
| 85 | + role-to-assume: ${{ secrets.GP_SPHINX_DOCS_ROLE_ARN }} |
| 86 | + aws-region: us-east-1 |
| 87 | + |
| 88 | + - name: Push documentation to S3 |
| 89 | + if: env.PUBLISH == 'true' |
| 90 | + run: | |
| 91 | + aws s3 sync docs/_build/html "s3://${{ secrets.GP_SPHINX_DOCS_BUCKET }}" \ |
| 92 | + --delete --follow-symlinks |
| 93 | +
|
| 94 | + - name: Invalidate CloudFront |
| 95 | + if: env.PUBLISH == 'true' |
| 96 | + run: | |
| 97 | + aws cloudfront create-invalidation \ |
| 98 | + --distribution-id "${{ secrets.GP_SPHINX_DOCS_DISTRIBUTION }}" \ |
| 99 | + --paths "/index.html" "/objects.inv" "/searchindex.js" |
| 100 | +
|
| 101 | + - name: Purge cache on Cloudflare |
| 102 | + if: env.PUBLISH == 'true' |
| 103 | + uses: jakejarvis/[email protected] |
| 104 | + env: |
| 105 | + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} |
| 106 | + CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }} |
0 commit comments