diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 4a934f490..8d30dd888 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -5,14 +5,11 @@ on: branches: [develop] workflow_dispatch: inputs: - environment: - description: 'Backend environment' + backend_url: + description: 'Backend Base URL (e.g. https://agent.bytedev.site/)' required: true - default: 'alpha' - type: choice - options: - - alpha - - production + default: 'https://agent.bytedev.site/' + type: string jobs: deploy-gh-pages: @@ -40,18 +37,26 @@ jobs: run: pnpm install - name: add environment variable + env: + ENV_BACKEND_URL: ${{ github.event.inputs.backend_url || 'https://agent.bytedev.site/' }} run: | - ENV=${{ github.event.inputs.environment || 'alpha' }} - VITE_ORIGIN_URL="https://agent-alpha.opentiny.design/" - if [ "$ENV" = "production" ]; then - VITE_ORIGIN_URL="https://agent.opentiny.design/" + if [[ "$ENV_BACKEND_URL" == *$'\n'* || "$ENV_BACKEND_URL" == *$'\r'* ]]; then + echo "::error::backend_url must be a single-line value" + exit 1 fi + + if [[ ! "$ENV_BACKEND_URL" =~ ^https?://[^[:space:]/?#:]+(:[0-9]+)?(/[^[:space:]?#]*)?$ ]]; then + echo "::error::backend_url must be an http(s) base URL without query or hash" + exit 1 + fi + + ENV_BACKEND_URL="${ENV_BACKEND_URL%/}/" + cat <> designer-demo/env/.env.alpha # ---- appended by CI (gh-pages) ---- - VITE_ORIGIN=$VITE_ORIGIN_URL + VITE_ORIGIN=$ENV_BACKEND_URL EOF - echo "DEPLOY_ENV=$ENV" - echo "VITE_ORIGIN_URL=$VITE_ORIGIN_URL" + echo "VITE_ORIGIN_URL=$ENV_BACKEND_URL" - name: Run Build run: | set -eo pipefail @@ -66,4 +71,4 @@ jobs: keep_files: true force_orphan: false user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' + user_email: 'github-actions[bot]@users.noreply.github.com' \ No newline at end of file