Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
uses: ./.github/workflows/wrangler-deploy.yml
with:
environment: production
worker_name: website
site_url: https://johnhooks.io
domains: johnhooks.io,www.johnhooks.io
ref: ${{ inputs.ref }}
secrets:
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
uses: ./.github/workflows/wrangler-deploy.yml
with:
environment: staging
worker_name: website-staging
site_url: https://website-staging.johnhooks.workers.dev
ref: ${{ inputs.ref }}
secrets:
Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/wrangler-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ on:
type: string
description: Git ref to deploy
default: ""
worker_name:
required: true
type: string
description: Worker name to deploy
domains:
required: false
type: string
description: Comma-separated custom domains for this environment
default: ""
secrets:
cloudflare_api_token:
required: true
Expand All @@ -42,9 +51,25 @@ jobs:
SITE_URL: ${{ inputs.site_url }}

- name: Deploy to Cloudflare
run: >-
pnpm wrangler deploy --env ${{ inputs.environment }} --var ENVIRONMENT:${{
inputs.environment }} --var SITE_URL:${{ inputs.site_url }}
run: |
domain_args=()
IFS=',' read -ra domains <<< "$DOMAINS"
for domain in "${domains[@]}"; do
if [[ -n "$domain" ]]; then
domain_args+=(--domain "$domain")
fi
done

pnpm wrangler deploy \
--env "$ENVIRONMENT" \
--name "$WORKER_NAME" \
"${domain_args[@]}" \
--var "ENVIRONMENT:$ENVIRONMENT" \
--var "SITE_URL:$SITE_URL"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.cloudflare_api_token }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.cloudflare_account_id }}
ENVIRONMENT: ${{ inputs.environment }}
WORKER_NAME: ${{ inputs.worker_name }}
SITE_URL: ${{ inputs.site_url }}
DOMAINS: ${{ inputs.domains }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"deploy": "pnpm build && wrangler deploy --env production --var ENVIRONMENT:production --var SITE_URL:https://johnhooks.io",
"deploy:staging": "pnpm build && wrangler deploy --env staging --var ENVIRONMENT:staging --var SITE_URL:https://website-staging.johnhooks.workers.dev",
"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",
"deploy:staging": "pnpm build && wrangler deploy --env staging --name website-staging --var ENVIRONMENT:staging --var SITE_URL:https://website-staging.johnhooks.workers.dev",
"check": "astro check",
"test": "vitest run",
"lint": "prettier --check . && eslint .",
Expand Down