Skip to content

Commit c500f0a

Browse files
committed
ci: update preview for worker
1 parent e877f07 commit c500f0a

1 file changed

Lines changed: 56 additions & 58 deletions

File tree

.github/workflows/preview.yml

Lines changed: 56 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,61 @@
11
name: Preview Deployment
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
6-
branches: [main]
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches: [main]
77

88
jobs:
9-
deploy-preview:
10-
runs-on: ubuntu-latest
11-
environment: production
12-
permissions:
13-
contents: read
14-
deployments: write
15-
pull-requests: write
16-
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Setup pnpm
22-
uses: pnpm/action-setup@v4
23-
with:
24-
version: 10
25-
26-
- name: Setup Node.js
27-
uses: actions/setup-node@v4
28-
with:
29-
node-version: '22'
30-
cache: pnpm
31-
32-
- name: Install dependencies
33-
run: pnpm install --frozen-lockfile
34-
35-
- name: Generate and Build
36-
run: |
37-
pnpm generate:data
38-
pnpm generate:og
39-
pnpm build
40-
env:
41-
NODE_VERSION: '22'
42-
43-
- name: Deploy Preview to Cloudflare Pages
44-
id: preview
45-
uses: cloudflare/wrangler-action@v3
46-
with:
47-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
48-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
49-
command: pages deploy dist --project-name=4byte-dev --branch=${{ github.head_ref }}
50-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
51-
wranglerVersion: '3'
52-
53-
- name: Add or Update PR Comment
54-
uses: marocchino/sticky-pull-request-comment@v2
55-
with:
56-
header: preview-url
57-
message: |
58-
**Preview Deployment is Ready!**
59-
60-
You can test the updates in this PR in a live environment by clicking the link below:
61-
[View Preview](${{ steps.preview.outputs.deployment-url }})
62-
63-
*(This environment is specific to this PR and does not affect the `main` branch. The content at this link will update automatically when you push new commits to the PR.)*
9+
deploy-preview:
10+
runs-on: ubuntu-latest
11+
environment: production
12+
13+
permissions:
14+
contents: read
15+
deployments: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 10
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
31+
cache: pnpm
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Install Wrangler
37+
run: pnpm add -D wrangler@4
38+
39+
- name: Build Astro
40+
run: |
41+
pnpm generate:data
42+
pnpm generate:og
43+
pnpm build
44+
45+
- name: Deploy Preview Worker
46+
id: deploy
47+
run: |
48+
cd dist/server
49+
npx wrangler deploy --name 4byte-dev-pr-${{ github.event.pull_request.number }}
50+
env:
51+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
52+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
53+
54+
- name: Add PR Comment
55+
uses: marocchino/sticky-pull-request-comment@v2
56+
with:
57+
header: preview-url
58+
message: |
59+
**Preview Deployment is Ready!**
60+
61+
https://4byte-dev-pr-${{ github.event.pull_request.number }}.<your-subdomain>.workers.dev

0 commit comments

Comments
 (0)