File tree Expand file tree Collapse file tree 2 files changed +30
-36
lines changed Expand file tree Collapse file tree 2 files changed +30
-36
lines changed Original file line number Diff line number Diff line change 66 pr_number :
77 required : true
88 type : string
9- commit_sha :
10- required : true
11- type : string
129 action :
1310 required : true
1411 type : string
2623 name : Deploy Preview
2724 runs-on : ubuntu-latest
2825 steps :
29- - name : Checkout PR branch for cache restore
30- if : inputs.action == 'create'
31- uses : actions/checkout@v4
32- with :
33- token : ${{ secrets.TOKEN }}
34- ref : ${{ inputs.commit_sha }}
35-
36- - name : Setup Node.js
37- uses : actions/setup-node@v4
38- with :
39- node-version : 20
40-
41- - name : Restore docs build output
42- if : inputs.action == 'create'
43- uses : actions/cache@v4
44- with :
45- path : |
46- build/docs/gatsby/public-preview
47- key : docs-build-${{ inputs.commit_sha }}
48- restore-keys : |
49- docs-build-
50-
5126 - name : Checkout gh-pages branch
5227 uses : actions/checkout@v4
5328 with :
5934 if : inputs.action == 'create'
6035 run : |
6136 mkdir -p gh-pages/preview/PR${{ inputs.pr_number }}
62- cp -r build/docs/gatsby/public-preview/* gh-pages/preview/PR${{ inputs.pr_number }}/
6337
38+ - name : Download preview build artifact
39+ if : inputs.action == 'create'
40+ uses : actions/download-artifact@v4
41+ with :
42+ name : preview-build-pr-${{ inputs.pr_number }}
43+ path : gh-pages/preview/PR${{ inputs.pr_number }}
44+
6445 - name : Remove preview directory
6546 if : inputs.action == 'delete'
6647 run : |
Original file line number Diff line number Diff line change 44 pull_request :
55 branches :
66 - main
7+ types :
8+ - opened
9+ - reopened
10+ - synchronize
11+ - closed
712 workflow_dispatch :
813
914permissions :
@@ -65,23 +70,31 @@ jobs:
6570 find public-preview -name "*.html" -exec sed -i 's|src="/execution-apis/|src="/execution-apis/preview/PR${{ github.event.number }}/|g' {} \;
6671 find public-preview -name "*.js" -exec sed -i 's|"/execution-apis/|"/execution-apis/preview/PR${{ github.event.number }}/|g' {} \;
6772 find public-preview -name "*.css" -exec sed -i 's|url(/execution-apis/|url(/execution-apis/preview/PR${{ github.event.number }}/|g' {} \;
68- - name : Cache docs build output
69- uses : actions/cache@v4
73+
74+ - name : Upload preview build artifact
75+ uses : actions/upload-artifact@v4
7076 with :
71- path : |
72- build/docs/gatsby/public-preview
73- key : docs-build-${{ github.sha }}
74- restore-keys : |
75- docs-build-
77+ name : preview-build-pr-${{ github.event.number }}
78+ path : build/docs/gatsby/public-preview
79+ retention-days : 1
7680
7781 deploy-preview :
7882 name : Deploy Preview
7983 needs : test-deploy-24
80- if : github.event_name == 'pull_request'
84+ if : github.event_name == 'pull_request' && github.event.action != 'closed'
85+ uses : ./.github/workflows/deploy-preview.yaml
86+ with :
87+ pr_number : ${{ github.event.number }}
88+ action : create
89+ secrets :
90+ TOKEN : ${{ secrets.GITHUB_TOKEN }}
91+
92+ remove-preview :
93+ name : Remove Preview
94+ if : github.event_name == 'pull_request' && github.event.action == 'closed'
8195 uses : ./.github/workflows/deploy-preview.yaml
8296 with :
8397 pr_number : ${{ github.event.number }}
84- commit_sha : ${{ github.sha }}
85- action : ${{ github.event.action == 'closed' && 'delete' || 'create' }}
98+ action : delete
8699 secrets :
87100 TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments