Skip to content

Commit 7223055

Browse files
authored
chore(ci): deploy workflow support custom backend url (#1810)
* chore(ci): change deploy workflow backend input from environment choice to custom URL - Replace alpha/production dropdown with a string input for backend URL - Default to https://agent.bytedev.site/ - Allows any custom backend URL to be specified at dispatch time
1 parent 6390a94 commit 7223055

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

.github/workflows/deploy-gh-pages.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ on:
55
branches: [develop]
66
workflow_dispatch:
77
inputs:
8-
environment:
9-
description: 'Backend environment'
8+
backend_url:
9+
description: 'Backend Base URL (e.g. https://agent.bytedev.site/)'
1010
required: true
11-
default: 'alpha'
12-
type: choice
13-
options:
14-
- alpha
15-
- production
11+
default: 'https://agent.bytedev.site/'
12+
type: string
1613

1714
jobs:
1815
deploy-gh-pages:
@@ -40,18 +37,26 @@ jobs:
4037
run: pnpm install
4138

4239
- name: add environment variable
40+
env:
41+
ENV_BACKEND_URL: ${{ github.event.inputs.backend_url || 'https://agent.bytedev.site/' }}
4342
run: |
44-
ENV=${{ github.event.inputs.environment || 'alpha' }}
45-
VITE_ORIGIN_URL="https://agent-alpha.opentiny.design/"
46-
if [ "$ENV" = "production" ]; then
47-
VITE_ORIGIN_URL="https://agent.opentiny.design/"
43+
if [[ "$ENV_BACKEND_URL" == *$'\n'* || "$ENV_BACKEND_URL" == *$'\r'* ]]; then
44+
echo "::error::backend_url must be a single-line value"
45+
exit 1
4846
fi
47+
48+
if [[ ! "$ENV_BACKEND_URL" =~ ^https?://[a-zA-Z0-9._-]+(:[0-9]+)?(/[a-zA-Z0-9._/~:%-]*)?$ ]]; then
49+
echo "::error::backend_url must be an http(s) base URL using only URL-safe characters (letters, digits, . _ - / ~ : %)"
50+
exit 1
51+
fi
52+
53+
ENV_BACKEND_URL="${ENV_BACKEND_URL%/}/"
54+
4955
cat <<EOF >> designer-demo/env/.env.alpha
5056
# ---- appended by CI (gh-pages) ----
51-
VITE_ORIGIN=$VITE_ORIGIN_URL
57+
VITE_ORIGIN=$ENV_BACKEND_URL
5258
EOF
53-
echo "DEPLOY_ENV=$ENV"
54-
echo "VITE_ORIGIN_URL=$VITE_ORIGIN_URL"
59+
echo "VITE_ORIGIN_URL=$ENV_BACKEND_URL"
5560
- name: Run Build
5661
run: |
5762
set -eo pipefail
@@ -66,4 +71,4 @@ jobs:
6671
keep_files: true
6772
force_orphan: false
6873
user_name: 'github-actions[bot]'
69-
user_email: 'github-actions[bot]@users.noreply.github.com'
74+
user_email: 'github-actions[bot]@users.noreply.github.com'

0 commit comments

Comments
 (0)