Skip to content

Commit 16c3b2e

Browse files
authored
fix preview checkout (#4468)
* fix preview checkout * coderabbit recommended issues: write permission * coderabbitAI implement security improvement * newline
1 parent 9baef76 commit 16c3b2e

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
name: 'Preview Deployment'
22
on:
33
pull_request_target:
4+
types: [opened, synchronize, reopened]
45
branches:
56
- master
67

78
jobs:
8-
deploy:
9-
permissions:
10-
actions: read
11-
contents: read
12-
deployments: write
13-
pull-requests: write
9+
# Job 1: Build the code (no secrets here)
10+
build:
1411
runs-on: ubuntu-latest
15-
timeout-minutes: 5
1612
steps:
1713
- name: Checkout code
1814
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
persist-credentials: false # Don't persist GitHub token
1918

2019
- name: Cache node_modules
2120
uses: actions/cache@v4
@@ -32,6 +31,29 @@ jobs:
3231
- run: yarn install
3332
- run: yarn build
3433

34+
- name: Upload build artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: dist-files
38+
path: src/dist
39+
40+
# Job 2: Deploy with secrets (no PR code checkout)
41+
deploy:
42+
needs: build # Wait for build job to complete
43+
permissions:
44+
actions: read
45+
contents: read
46+
deployments: write
47+
issues: write
48+
pull-requests: write
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Download build artifact
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: dist-files
55+
path: src/dist
56+
3557
- name: Deploy to Cloudflare
3658
id: deploy
3759
uses: cloudflare/wrangler-action@v3

0 commit comments

Comments
 (0)