Skip to content

Commit b48b8f3

Browse files
authored
Merge pull request #15 from layer5io/leecalcote-patch-3
Enhance build workflow for pull request events
2 parents d136a9f + 5ab1d45 commit b48b8f3

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/build-and-preview-site.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ name: Build and Preview Site
22
on:
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

715
jobs:
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: |
@@ -32,3 +40,32 @@ jobs:
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

0 commit comments

Comments
 (0)