File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+
9+ jobs :
10+ deploy :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ deployments : write
15+
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Setup Node.js
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : ' 20'
23+ cache : ' npm'
24+
25+ - name : Install dependencies
26+ run : npm ci
27+
28+ - name : Build
29+ run : npm run build
30+ env :
31+ NODE_ENV : production
32+
33+ - name : Deploy to Cloudflare (Preview for PR / Production for main)
34+ uses : cloudflare/wrangler-action@v3
35+ with :
36+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
37+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
38+ command : |
39+ if [ "${{ github.event_name }}" = "pull_request" ]; then
40+ # Deploy to preview with unique name based on PR number
41+ opennextjs-cloudflare build
42+ wrangler deploy --env preview --name sparkmemos-pr-${{ github.event.pull_request.number }}
43+ else
44+ # Deploy to production
45+ opennextjs-cloudflare deploy
46+ fi
47+
48+ - name : Deploy status comment
49+ if : github.event_name == 'pull_request'
50+ uses : actions/github-script@v7
51+ with :
52+ script : |
53+ const previewUrl = `https://sparkmemos-pr-${{ github.event.pull_request.number }}.workers.dev`;
54+ await github.rest.issues.createComment({
55+ owner: context.repo.owner,
56+ repo: context.repo.repo,
57+ issue_number: context.payload.pull_request.number,
58+ body: `🚀 Preview deployed: ${previewUrl}`
59+ });
You can’t perform that action at this time.
0 commit comments