Skip to content

Commit a5dec44

Browse files
committed
chore: update workflow
1 parent 74efaaf commit a5dec44

3 files changed

Lines changed: 76 additions & 171 deletions

File tree

.github/workflows/cloudflare-preview-build.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/cloudflare-preview-deploy.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Cloudflare Workers Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: cloudflare-preview-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
deploy-preview:
14+
runs-on: ubuntu-latest
15+
if: github.repository == 'doocs/md'
16+
permissions:
17+
contents: read
18+
deployments: write
19+
pull-requests: write
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v5
23+
with:
24+
ref: ${{ github.event.pull_request.head.sha }}
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v6
28+
with:
29+
node-version: 22
30+
31+
- name: Setup pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 10
35+
36+
- name: Install dependencies
37+
run: pnpm install
38+
39+
- name: Build for Cloudflare Workers
40+
run: pnpm web build:h5-netlify
41+
env:
42+
CF_WORKERS: 1
43+
44+
- name: Deploy to Cloudflare Workers
45+
id: deploy
46+
uses: cloudflare/wrangler-action@v3
47+
with:
48+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
49+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
50+
command: deploy --name md-pr-${{ github.event.pull_request.number }}
51+
workingDirectory: apps/web
52+
env:
53+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
54+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
55+
56+
- name: Get deployment URL
57+
id: deployment-url
58+
run: |
59+
PREVIEW_URL="https://md-pr-${{ github.event.pull_request.number }}.doocs.workers.dev"
60+
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT
61+
echo "Preview URL: $PREVIEW_URL"
62+
63+
- name: Comment PR with preview link
64+
uses: actions-cool/maintain-one-comment@v3
65+
with:
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
body: |
68+
🚀 Cloudflare Workers Preview has been successfully deployed!
69+
70+
**Preview URL:** ${{ steps.deployment-url.outputs.url }}
71+
72+
<sub>Built with commit ${{ github.event.pull_request.head.sha }}</sub>
73+
74+
<!-- Cloudflare Preview Comment -->
75+
body-include: '<!-- Cloudflare Preview Comment -->'
76+
number: ${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)