From fa1b9523a1027652412dc4fb0885cded9380215c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Trkan?= Date: Mon, 6 Oct 2025 20:56:42 +0200 Subject: [PATCH] feat(infrastructure): add frontend, deploy to cloudflare --- .github/workflows/frontend-pages.yml | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/frontend-pages.yml b/.github/workflows/frontend-pages.yml index d6af8aa..e8be774 100644 --- a/.github/workflows/frontend-pages.yml +++ b/.github/workflows/frontend-pages.yml @@ -60,21 +60,37 @@ 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 }} + 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 - if echo "$PROD_DOMAIN" | grep -Eiq '^https?://'; then - URL="$PROD_DOMAIN" + # 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://${PROD_DOMAIN}" + URL="https://${BACKEND_URL_OVERRIDE}" fi - fi - if [ "${MODE:-}" = "pr" ] || [ "${EVENT_NAME}" = "pull_request" ]; then - if [ -n "${PR_TEMPLATE:-}" ] && [ -n "${PR_NUMBER:-}" ] ; then - URL="${PR_TEMPLATE//\{PR\}/${PR_NUMBER}}" + else + # 2) PR template 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}}" + 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 fi fi echo "Using backend URL: ${URL:-}"