Compare commits

11 Commits

Author SHA1 Message Date
dbd37a8b83 feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 21:36:30 +02:00
f1cbdbce9c update 2025-10-06 21:29:35 +02:00
fa1b9523a1 feat(infrastructure): add frontend, deploy to cloudflare
Some checks failed
Deploy Prod / Build and push image (reusable) (push) Has been cancelled
Deploy Prod / Frontend - Build and Deploy to Cloudflare Pages (prod) (push) Has been cancelled
Deploy Prod / Helm upgrade/install (prod) (push) Has been cancelled
2025-10-06 20:56:42 +02:00
e5fceb886b feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:48:01 +02:00
ec7c0cbc7a Merge pull request #16 from dat515-2025/merge/cloudflare-deploy
feat(infrastructure): add frontend, deploy to cloudflare
2025-10-06 18:44:31 +02:00
9ea02ed10c feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:39:38 +02:00
afb8199cad feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:37:35 +02:00
1e23b32f30 feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:26:17 +02:00
cdfaf3e66d feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:23:52 +02:00
21ccb00f4a feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:12:39 +02:00
901fff8651 feat(infrastructure): add frontend, deploy to cloudflare 2025-10-06 18:09:23 +02:00
5 changed files with 51 additions and 32 deletions

View File

@@ -60,8 +60,8 @@ jobs:
- name: Helm upgrade/install PR preview
env:
DEV_BASE_DOMAIN: ${{ secrets.BASE_DOMAIN }}
RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
RABBITMQ_PASSWORD: ${{ secrets.PROD_RABBITMQ_PASSWORD }}
DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
IMAGE_REPO: ${{ needs.build.outputs.image_repo }}
DIGEST: ${{ needs.build.outputs.digest }}
run: |
@@ -114,7 +114,7 @@ jobs:
uninstall:
if: github.event.action == 'closed'
name: Helm uninstall (PR preview)
runs-on: ubuntu-latest
runs-on: vhs
steps:
- name: Setup Helm
uses: azure/setup-helm@v4

View File

@@ -5,9 +5,11 @@ on:
branches: [ "main" ]
paths:
- 7project/backend/**
- 7project/frontend/**
- 7project/charts/myapp-chart/**
- .github/workflows/deploy-prod.yaml
- .github/workflows/build-image.yaml
- .github/workflows/frontend-pages.yml
workflow_dispatch:
@@ -38,7 +40,7 @@ jobs:
deploy:
name: Helm upgrade/install (prod)
runs-on: vhs
needs: [build]
needs: [build, frontend]
steps:
- name: Checkout
uses: actions/checkout@v4

View File

@@ -24,22 +24,6 @@ on:
deployed_url:
description: 'URL of deployed frontend'
value: ${{ jobs.deploy.outputs.deployed_url }}
push:
branches: [ "main" ]
paths:
- '7project/frontend/**'
- '.github/workflows/frontend-pages.yml'
pull_request:
branches: [ "main" ]
paths:
- '7project/frontend/**'
- '.github/workflows/frontend-pages.yml'
workflow_dispatch:
inputs:
project_name:
description: 'Cloudflare Pages project name (overrides default)'
required: false
type: string
# Required repository secrets:
# CLOUDFLARE_API_TOKEN - API token with Pages:Edit (or Account:Workers Scripts:Edit) permissions
@@ -76,21 +60,40 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }}
PR_TEMPLATE: ${{ vars.BACKEND_URL_PR_TEMPLATE }}
PROD_DOMAIN: ${{ vars.PROD_DOMAIN }}
DEV_BASE_DOMAIN: ${{ secrets.BASE_DOMAIN }}
PROD_DOMAIN_VAR: ${{ vars.PROD_DOMAIN }}
PROD_DOMAIN_SECRET: ${{ secrets.PROD_DOMAIN }}
BACKEND_URL_OVERRIDE: ${{ vars.BACKEND_URL || secrets.BACKEND_URL }}
MODE: ${{ inputs.mode }}
run: |
set -euo pipefail
URL=""
if [ -n "${PROD_DOMAIN:-}" ]; then
# 1) Explicit override wins (from repo var or secret)
if [ -n "${BACKEND_URL_OVERRIDE:-}" ]; then
if echo "$BACKEND_URL_OVERRIDE" | grep -Eiq '^https?://'; then
URL="$BACKEND_URL_OVERRIDE"
else
URL="https://${BACKEND_URL_OVERRIDE}"
fi
else
# 2) PR-specific URL when building for PR
if [ "${MODE:-}" = "pr" ] || [ "${EVENT_NAME}" = "pull_request" ]; then
if [ -n "${PR_TEMPLATE:-}" ] && [ -n "${PR_NUMBER:-}" ] ; then
URL="${PR_TEMPLATE//\{PR\}/${PR_NUMBER}}"
elif [ -n "${DEV_BASE_DOMAIN:-}" ] && [ -n "${PR_NUMBER:-}" ]; then
URL="https://pr-${PR_NUMBER}.${DEV_BASE_DOMAIN}"
fi
fi
# 3) Fallback to PROD_DOMAIN (prefer repo var, then secret)
if [ -z "$URL" ]; then
PROD_DOMAIN="${PROD_DOMAIN_VAR:-${PROD_DOMAIN_SECRET:-}}"
if [ -n "$PROD_DOMAIN" ]; then
if echo "$PROD_DOMAIN" | grep -Eiq '^https?://'; then
URL="$PROD_DOMAIN"
else
URL="https://${PROD_DOMAIN}"
fi
fi
if [ "${MODE:-}" = "pr" ] || [ "${EVENT_NAME}" = "pull_request" ]; then
if [ -n "${PR_TEMPLATE:-}" ] && [ -n "${PR_NUMBER:-}" ] ; then
URL="${PR_TEMPLATE//\{PR\}/${PR_NUMBER}}"
fi
fi
echo "Using backend URL: ${URL:-<empty>}"
@@ -131,9 +134,11 @@ jobs:
# Prefer manual input, then repo variable, fallback to repo-name
INPUT_NAME='${{ inputs.project_name }}'
VAR_NAME='${{ vars.CF_PAGES_PROJECT_NAME }}'
if [ -n "$INPUT_NAME" ]; then PNAME="$INPUT_NAME";
elif [ -n "$VAR_NAME" ]; then PNAME="$VAR_NAME";
else PNAME="${GITHUB_REPOSITORY##*/}-frontend"; fi
if [ -n "$INPUT_NAME" ]; then PNAME_RAW="$INPUT_NAME";
elif [ -n "$VAR_NAME" ]; then PNAME_RAW="$VAR_NAME";
else PNAME_RAW="${GITHUB_REPOSITORY##*/}-frontend"; fi
# Normalize project name to lowercase to satisfy Cloudflare Pages naming
PNAME="${PNAME_RAW,,}"
# Determine branch for Pages
if [ "${INPUT_MODE}" = "pr" ]; then
if [ -z "${INPUT_PR}" ]; then echo "pr_number is required when mode=pr"; exit 1; fi
@@ -144,6 +149,15 @@ jobs:
echo "project_name=$PNAME" >> $GITHUB_OUTPUT
echo "branch=$PBRANCH" >> $GITHUB_OUTPUT
- name: Ensure Cloudflare Pages project exists
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
PNAME: ${{ steps.pname.outputs.project_name }}
run: |
set -euo pipefail
npx wrangler pages project create "$PNAME" --production-branch=main || true
- name: Deploy using Cloudflare Wrangler
uses: cloudflare/wrangler-action@v3
with:

View File

@@ -29,6 +29,7 @@ worker:
# Queue name for Celery worker and for CRD Queue
mailQueueName: "mail_queue"
service:
port: 80

View File

@@ -0,0 +1,2 @@
export const BACKEND_URL: string =
import.meta.env.VITE_BACKEND_URL ?? '';