Skip to content

Commit 0c9d392

Browse files
committed
ci: add commit sha and message in upload
1 parent 48eea8a commit 0c9d392

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,44 @@ name: Deploy
22

33
on:
44
push:
5-
branches: ['master']
5+
branches: [master]
66

77
jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- name: Checkout code
12+
uses: actions/checkout@v4
1213

13-
- uses: actions/setup-node@v4
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
1416
with:
1517
node-version: 22
16-
cache: 'npm'
18+
cache: npm
1719

1820
- name: Install dependencies
1921
run: npm ci
2022

2123
- name: Build
2224
run: npm run build
2325

26+
- name: Upload with Wrangler
27+
id: wrangler_upload
28+
run: |
29+
short_sha=$(echo $GITHUB_SHA | cut -c1-7)
30+
output=$(npx wrangler versions upload --env "" --tag "$short_sha" --message "${{ github.event.head_commit.message }}")
31+
echo "$output"
32+
33+
version_id=$(echo "$output" | grep -oP 'Worker Version ID: \K[a-f0-9-]{36}')
34+
echo "version_id=$version_id" >> $GITHUB_OUTPUT
35+
36+
echo "Uploaded $short_sha as $version_id"
37+
env:
38+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
39+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
40+
2441
- name: Deploy with Wrangler
25-
uses: cloudflare/wrangler-action@v3
26-
with:
27-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
28-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
42+
run: npx wrangler versions deploy --env "" --version-id ${{ steps.wrangler_upload.outputs.version_id }} --yes
43+
env:
44+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
45+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

.github/workflows/pr-lint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ name: Lint PR
22

33
on:
44
pull_request:
5-
branches: ['master']
5+
branches: [master]
66

77
jobs:
88
lint:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- name: Checkout code
12+
uses: actions/checkout@v4
1213

13-
- uses: actions/setup-node@v4
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
1416
with:
1517
node-version: 22
16-
cache: 'npm'
18+
cache: npm
1719

1820
- name: Install dependencies
1921
run: npm ci

.github/workflows/pr-preview.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ jobs:
4040
return response.data.head.sha;
4141
result-encoding: string
4242

43-
- uses: actions/checkout@v4
43+
- name: Checkout code
44+
uses: actions/checkout@v4
4445
with:
4546
ref: ${{ steps.pr_sha.outputs.result }}
4647

47-
- uses: actions/setup-node@v4
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
4850
with:
4951
node-version: 22
50-
cache: 'npm'
52+
cache: npm
5153

5254
- name: Install dependencies
5355
run: npm ci

0 commit comments

Comments
 (0)