Deploy preview #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test deployment | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| test-deploy: | |
| name: Test deployment | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20, 22] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm install --frozen-lockfile | |
| - name: Test build website | |
| run: | | |
| npm run build | |
| npm run build:docs | |
| test-deploy-24: | |
| name: Deploy 24 | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| strategy: | |
| matrix: | |
| node-version: [24] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm install --frozen-lockfile | |
| - name: Build docs | |
| run: | | |
| npm run build | |
| npm run build:docs | |
| - name: Create preview build | |
| run: | | |
| cd build/docs/gatsby | |
| # Copy the built files for preview | |
| cp -r public public-preview | |
| # Fix paths in the preview build | |
| find public-preview -name "*.html" -exec sed -i 's|href="/execution-apis/|href="/execution-apis/preview/PR${{ github.event.number }}/|g' {} \; | |
| find public-preview -name "*.html" -exec sed -i 's|src="/execution-apis/|src="/execution-apis/preview/PR${{ github.event.number }}/|g' {} \; | |
| find public-preview -name "*.js" -exec sed -i 's|"/execution-apis/|"/execution-apis/preview/PR${{ github.event.number }}/|g' {} \; | |
| find public-preview -name "*.css" -exec sed -i 's|url(/execution-apis/|url(/execution-apis/preview/PR${{ github.event.number }}/|g' {} \; | |
| - name: Cache docs build output | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| build/docs/gatsby/public | |
| build/docs/gatsby/public-preview | |
| key: docs-build-${{ github.sha }} | |
| restore-keys: | | |
| docs-build- | |
| deploy-preview: | |
| name: Deploy Preview | |
| needs: test-deploy-24 | |
| if: github.event_name == 'pull_request' | |
| uses: ./.github/workflows/deploy-preview.yaml | |
| with: | |
| pr_number: ${{ github.event.number }} | |
| commit_sha: ${{ github.sha }} | |
| action: ${{ github.event.action == 'closed' && 'delete' || 'create' }} | |
| secrets: | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} |