Skip to content

Commit 37e6aa3

Browse files
committed
ci: fix wrangler deploy domain
1 parent 5ed723b commit 37e6aa3

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

.github/workflows/deploy-production.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ jobs:
1414
uses: ./.github/workflows/wrangler-deploy.yml
1515
with:
1616
environment: production
17+
worker_name: website
1718
site_url: https://johnhooks.io
19+
domains: johnhooks.io,www.johnhooks.io
1820
ref: ${{ inputs.ref }}
1921
secrets:
2022
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.github/workflows/deploy-staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: ./.github/workflows/wrangler-deploy.yml
1818
with:
1919
environment: staging
20+
worker_name: website-staging
2021
site_url: https://website-staging.johnhooks.workers.dev
2122
ref: ${{ inputs.ref }}
2223
secrets:

.github/workflows/wrangler-deploy.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ on:
1616
type: string
1717
description: Git ref to deploy
1818
default: ""
19+
worker_name:
20+
required: true
21+
type: string
22+
description: Worker name to deploy
23+
domains:
24+
required: false
25+
type: string
26+
description: Comma-separated custom domains for this environment
27+
default: ""
1928
secrets:
2029
cloudflare_api_token:
2130
required: true
@@ -42,9 +51,25 @@ jobs:
4251
SITE_URL: ${{ inputs.site_url }}
4352

4453
- name: Deploy to Cloudflare
45-
run: >-
46-
pnpm wrangler deploy --env ${{ inputs.environment }} --var ENVIRONMENT:${{
47-
inputs.environment }} --var SITE_URL:${{ inputs.site_url }}
54+
run: |
55+
domain_args=()
56+
IFS=',' read -ra domains <<< "$DOMAINS"
57+
for domain in "${domains[@]}"; do
58+
if [[ -n "$domain" ]]; then
59+
domain_args+=(--domain "$domain")
60+
fi
61+
done
62+
63+
pnpm wrangler deploy \
64+
--env "$ENVIRONMENT" \
65+
--name "$WORKER_NAME" \
66+
"${domain_args[@]}" \
67+
--var "ENVIRONMENT:$ENVIRONMENT" \
68+
--var "SITE_URL:$SITE_URL"
4869
env:
4970
CLOUDFLARE_API_TOKEN: ${{ secrets.cloudflare_api_token }}
5071
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.cloudflare_account_id }}
72+
ENVIRONMENT: ${{ inputs.environment }}
73+
WORKER_NAME: ${{ inputs.worker_name }}
74+
SITE_URL: ${{ inputs.site_url }}
75+
DOMAINS: ${{ inputs.domains }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"dev": "astro dev",
2020
"build": "astro build",
2121
"preview": "astro preview",
22-
"deploy": "pnpm build && wrangler deploy --env production --var ENVIRONMENT:production --var SITE_URL:https://johnhooks.io",
23-
"deploy:staging": "pnpm build && wrangler deploy --env staging --var ENVIRONMENT:staging --var SITE_URL:https://website-staging.johnhooks.workers.dev",
22+
"deploy": "pnpm build && wrangler deploy --env production --name website --domain johnhooks.io --domain www.johnhooks.io --var ENVIRONMENT:production --var SITE_URL:https://johnhooks.io",
23+
"deploy:staging": "pnpm build && wrangler deploy --env staging --name website-staging --var ENVIRONMENT:staging --var SITE_URL:https://website-staging.johnhooks.workers.dev",
2424
"check": "astro check",
2525
"test": "vitest run",
2626
"lint": "prettier --check . && eslint .",

0 commit comments

Comments
 (0)