|
| 1 | +# GHA workflow which publishes previews of the docs to Netlify. |
| 2 | +# |
| 3 | +# We keep this in a separate workflow to the main build, because it |
| 4 | +# requires access to the Netlify secret. By having it run on `workflow_run`, we |
| 5 | +# will only use the workflow definition file on the default branch, so we can |
| 6 | +# ensure that the secret can't be exfiltrated. |
| 7 | + |
| 8 | +name: Deploy documentation PR preview |
| 9 | + |
| 10 | +on: |
| 11 | + workflow_run: |
| 12 | + workflows: ["CI"] |
| 13 | + types: |
| 14 | + - completed |
| 15 | + |
| 16 | +permissions: {} |
| 17 | + |
| 18 | +jobs: |
| 19 | + netlify: |
| 20 | + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' |
| 21 | + runs-on: ubuntu-24.04 |
| 22 | + permissions: |
| 23 | + actions: read |
| 24 | + deployments: write |
| 25 | + |
| 26 | + # Tell github to share the right secrets |
| 27 | + environment: PR Documentation Preview |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: 📥 Download artifact |
| 31 | + uses: actions/download-artifact@v4 |
| 32 | + with: |
| 33 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + run-id: ${{ github.event.workflow_run.id }} |
| 35 | + name: docs |
| 36 | + path: docs |
| 37 | + |
| 38 | + - name: 📤 Deploy to Netlify |
| 39 | + uses: matrix-org/netlify-pr-preview@v3 |
| 40 | + with: |
| 41 | + path: docs |
| 42 | + |
| 43 | + # Pass the details of the workflow run that just completed into the action. |
| 44 | + # This allows it to figure out the PR number. |
| 45 | + owner: ${{ github.event.workflow_run.head_repository.owner.login }} |
| 46 | + branch: ${{ github.event.workflow_run.head_branch }} |
| 47 | + revision: ${{ github.event.workflow_run.head_sha }} |
| 48 | + |
| 49 | + token: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 50 | + site_id: dcaf4b8b-3a2d-4498-ad8f-ca73f36a43e0 |
| 51 | + |
| 52 | + desc: Documentation preview |
| 53 | + deployment_env: PR Documentation Preview |
| 54 | + |
0 commit comments