Skip to content

Commit 05b6fa5

Browse files
committed
implement security improvement
1 parent b044d60 commit 05b6fa5

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ on:
66
- master
77

88
jobs:
9-
deploy:
10-
permissions:
11-
actions: read
12-
contents: read
13-
deployments: write
14-
issues: write
15-
pull-requests: write
9+
# Job 1: Build the code (no secrets here)
10+
build:
1611
runs-on: ubuntu-latest
17-
timeout-minutes: 5
1812
steps:
1913
- name: Checkout code
2014
uses: actions/checkout@v4
2115
with:
2216
ref: ${{ github.event.pull_request.head.sha }}
17+
persist-credentials: false # Don't persist GitHub token
2318

2419
- name: Cache node_modules
2520
uses: actions/cache@v4
@@ -36,6 +31,30 @@ jobs:
3631
- run: yarn install
3732
- run: yarn build
3833

34+
- name: Upload build artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: dist-files
38+
path: 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+
timeout-minutes: 5
51+
steps:
52+
- name: Download build artifact
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: dist-files
56+
path: dist
57+
3958
- name: Deploy to Cloudflare
4059
id: deploy
4160
uses: cloudflare/wrangler-action@v3

0 commit comments

Comments
 (0)