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