Skip to content

Commit 1122751

Browse files
fix
Signed-off-by: Rajesh-Nagarajan-11 <[email protected]>
1 parent caa66c4 commit 1122751

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build and Preview Site
22
on:
3-
pull_request:
3+
pull_request_target:
44
branches: [master]
55
types: [opened, synchronize, reopened, closed]
66

@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Checkout 🛎️
2020
uses: actions/checkout@v6
21+
with:
22+
ref: ${{ github.event.pull_request.head.sha }}
2123

2224
- name: Install and Build 🔧
2325
env:
@@ -46,23 +48,23 @@ jobs:
4648
preview:
4749
needs: build
4850
runs-on: ubuntu-latest
49-
if: github.event_name == 'pull_request'
51+
if: github.event_name == 'pull_request_target'
5052
permissions:
5153
contents: write
5254
pull-requests: write
5355
steps:
5456
- name: Checkout 🛎️
5557
uses: actions/checkout@v6
58+
with:
59+
ref: ${{ github.event.pull_request.base.ref }}
5660

5761
- name: Download pre-built site
58-
if: github.event_name == 'pull_request'
5962
uses: actions/download-artifact@v4
6063
with:
6164
name: public-dir
6265
path: .
6366

6467
- name: Extract site
65-
if: github.event_name == 'pull_request'
6668
run: |
6769
unzip -q public-dir.zip
6870
# Ensure the extracted folder has the static files in a 'public' dir for the action
@@ -73,14 +75,14 @@ jobs:
7375
fi
7476
7577
- name: Deploy Preview
76-
if: github.event_name == 'pull_request' && github.event.action != 'closed'
78+
if: github.event.action != 'closed'
7779
uses: rossjrw/[email protected]
7880
with:
7981
source-dir: public
8082
token: ${{ secrets.GITHUB_TOKEN }}
8183

8284
- name: Remove Preview on Close
83-
if: github.event_name == 'pull_request' && github.event.action == 'closed'
85+
if: github.event.action == 'closed'
8486
uses: rossjrw/[email protected]
8587
with:
8688
source-dir: public

0 commit comments

Comments
 (0)