-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.28 KB
/
preview-www-deployment.yaml
File metadata and controls
78 lines (67 loc) · 2.28 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
77
78
name: Preview WWW Deployment
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'apps/www/**'
- 'packages/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '!**/*.md'
- '!**/README*'
concurrency:
group: preview-www-${{ github.event.pull_request.number }}-${{ github.sha }}
cancel-in-progress: false
jobs:
deploy:
name: Deploy Preview to Cloudflare Workers
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Setup pnpm
uses: pnpm/action-setup@v5
with:
version: 10.14.0
- name: Cache pnpm store
uses: actions/cache@v5
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and upload version
id: deploy
working-directory: apps/www
run: |
pnpm run build
pnpm dlx wrangler versions upload 2>&1 | tee deploy-output.txt
VERSION_ID=$(grep -oP 'Version ID: \K[a-f0-9-]+' deploy-output.txt)
PREVIEW_URL=$(grep -oP 'https://[a-zA-Z0-9.-]+\.workers\.dev' deploy-output.txt | head -1)
echo "version_id=$VERSION_ID" >> $GITHUB_OUTPUT
echo "preview_url=$PREVIEW_URL" >> $GITHUB_OUTPUT
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Comment on PR
if: steps.deploy.outputs.preview_url != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "### Preview Deployment
**Commit:** \`${{ github.sha }}\`
**Version ID:** \`${{ steps.deploy.outputs.version_id }}\`
**Preview URL:** ${{ steps.deploy.outputs.preview_url }}
**Deployed at:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')"