Skip to content
Open
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
35 changes: 20 additions & 15 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 <<EOF >> 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
Expand All @@ -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'
Loading