File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,14 +2,22 @@ name: Build and Preview Site
22on :
33 pull_request :
44 branches : [master]
5- types : [opened, synchronize, reopened]
5+ types : [opened, synchronize, reopened, closed]
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.ref }}
9+ cancel-in-progress : true
10+
11+ permissions :
12+ contents : read
13+ pull-requests : write
614
715jobs :
8- site-preview :
16+ build :
917 runs-on : ubuntu-latest
1018 steps :
1119 - name : Checkout 🛎️
12- uses : actions/checkout@v4
20+ uses : actions/checkout@v6
1321
1422 - name : Install and Build 🔧
1523 run : |
3240 name : public-dir
3341 path : public-dir.zip
3442 retention-days : 1
43+
44+ preview :
45+ needs : build
46+ runs-on : ubuntu-latest
47+ if : github.event_name == 'pull_request'
48+ steps :
49+ - name : Download pre-built site
50+ if : github.event_name == 'pull_request'
51+ uses : actions/download-artifact@v4
52+ with :
53+ name : public-dir
54+ path : .
55+
56+ - name : Extract site
57+ if : github.event_name == 'pull_request'
58+ run : unzip -q public-dir.zip
59+
60+ - name : Deploy Preview
61+ if : github.event_name == 'pull_request' && github.event.action != 'closed'
62+ uses : rossjrw/pr-preview-action@v1
63+ with :
64+ source-dir : public-dir # ← this matches the folder created by your script.sh
65+
66+ - name : Remove Preview on Close
67+ if : github.event_name == 'pull_request' && github.event.action == 'closed'
68+ uses : rossjrw/pr-preview-action@v1
69+ with :
70+ source-dir : public-dir
71+ remove : true
You can’t perform that action at this time.
0 commit comments