-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (36 loc) · 1.32 KB
/
deploy.yml
File metadata and controls
45 lines (36 loc) · 1.32 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
name: Deploy
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload with Wrangler
id: wrangler_upload
run: |
short_sha=$(echo $GITHUB_SHA | cut -c1-7)
output=$(npx wrangler versions upload --env "" --tag "$short_sha" --message "${{ github.event.head_commit.message }}")
echo "$output"
version_id=$(echo "$output" | grep -oP 'Worker Version ID: \K[a-f0-9-]{36}')
echo "version_id=$version_id" >> $GITHUB_OUTPUT
echo "Uploaded $short_sha as $version_id"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy with Wrangler
run: npx wrangler versions deploy --env "" --version-id ${{ steps.wrangler_upload.outputs.version_id }} --yes
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}