File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,28 +32,11 @@ jobs:
3232 env :
3333 CF_WORKERS : 1
3434
35- - name : Prepare deployment files
36- run : |
37- # Copy wrangler config and worker code
38- mkdir -p deploy-package
39- cp -r apps/web/dist deploy-package/
40- cp apps/web/wrangler.jsonc deploy-package/wrangler.jsonc
41- cp -r apps/web/worker deploy-package/
42-
43- # Create a minimal package.json without workspace protocol
44- cat > deploy-package/package.json << 'EOF'
45- {
46- "name": "md-preview",
47- "version": "1.0.0",
48- "private": true
49- }
50- EOF
51-
5235 - name : Upload deployment package
5336 uses : actions/upload-artifact@v4
5437 with :
5538 name : cloudflare-dist
56- path : deploy-package
39+ path : dist
5740 retention-days : 5
5841
5942 - name : Save PR number
Original file line number Diff line number Diff line change 66 types :
77 - completed
88
9+ permissions :
10+ contents : read
11+ deployments : write
12+ pull-requests : write
13+
914jobs :
1015 deploy :
1116 runs-on : ubuntu-latest
1217 if : github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.repository == 'doocs/md'
13- permissions :
14- contents : read
15- deployments : write
16- pull-requests : write
1718 steps :
1819 - name : Checkout
1920 uses : actions/checkout@v5
2021
22+ - name : Set up node
23+ uses : actions/setup-node@v6
24+ with :
25+ node-version : 22
26+
27+ - name : Install Wrangler
28+ run : npm install -g wrangler@latest
29+
2130 - name : Download PR artifact
2231 uses : dawidd6/action-download-artifact@v11
2332 with :
@@ -42,23 +51,11 @@ jobs:
4251 run_id : ${{ github.event.workflow_run.id }}
4352 workflow_conclusion : success
4453 name : cloudflare-dist
45- path : deploy-package
54+ path : dist
4655
47- - name : Update wrangler config
56+ - name : Deploy to Cloudflare Workers (preview)
4857 run : |
49- cd deploy-package
50- # Update the assets directory path in wrangler.jsonc
51- sed -i 's|"directory": "./public/"|"directory": "./dist/"|g' wrangler.jsonc
52-
53- - name : Deploy to Cloudflare Workers
54- id : deploy
55- uses : cloudflare/wrangler-action@v3
56- with :
57- apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
58- accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
59- command : deploy --name md-pr-${{ steps.pr.outputs.id }}
60- workingDirectory : deploy-package
61- packageManager : npm
58+ wrangler deploy --name=md-pr-${{ steps.pr.outputs.id }} --env preview --assets ./dist
6259 env :
6360 CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
6461 CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
You can’t perform that action at this time.
0 commit comments