From ae36d05fe4477820d298134c0af3ab496e60df76 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 6 Aug 2026 16:18:19 +0800 Subject: [PATCH] fix(deploy): bake web base path for old HK helper Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .github/workflows/pr-batch-test-deploy.yml | 10 +++++-- docs/pr-batch-test-runtime.md | 7 +++-- scripts/deploy-test-runtime.sh | 31 ++++++++++++++-------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-batch-test-deploy.yml b/.github/workflows/pr-batch-test-deploy.yml index 5a9848ce..d745eb97 100644 --- a/.github/workflows/pr-batch-test-deploy.yml +++ b/.github/workflows/pr-batch-test-deploy.yml @@ -74,6 +74,7 @@ jobs: echo "key_file=${key_file}" >> "${GITHUB_OUTPUT}" - name: Preflight HK deploy helper + id: hk-helper env: TEST_RUNTIME_SSH_HOST: ${{ secrets.TEST_RUNTIME_SSH_HOST }} TEST_RUNTIME_SSH_USER: ${{ secrets.TEST_RUNTIME_SSH_USER }} @@ -82,6 +83,7 @@ jobs: WEB_BASE_PATH: ${{ inputs.web_base_path }} run: | if [[ -z "${PUBLIC_URL}" && -z "${WEB_BASE_PATH}" ]]; then + echo "subpath_supported=false" >> "${GITHUB_OUTPUT}" exit 0 fi @@ -99,10 +101,12 @@ jobs: if ! grep -Fq -- "--public-url" <<<"${helper_help}" || \ ! grep -Fq -- "--web-base-path" <<<"${helper_help}"; then - echo "::error::HK deploy helper is outdated. Install scripts/skillhub-test-deploy-remote.sh to /usr/local/bin/skillhub-test-deploy before sub-path validation." + echo "::warning::HK deploy helper is outdated. The workflow will bake the requested web base path into the web image, but the helper should still be updated to write SKILLHUB_PUBLIC_BASE_URL and SKILLHUB_WEB_API_BASE_URL at runtime." echo "${helper_help}" - exit 1 + echo "subpath_supported=false" >> "${GITHUB_OUTPUT}" + exit 0 fi + echo "subpath_supported=true" >> "${GITHUB_OUTPUT}" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -145,6 +149,8 @@ jobs: context: ./web file: ./web/Dockerfile platforms: ${{ env.DOCKER_PLATFORM }} + build-args: | + VITE_BASE_PATH=${{ inputs.web_base_path || '/__SKILLHUB_WEB_BASE_PATH__/' }} push: true provenance: false sbom: false diff --git a/docs/pr-batch-test-runtime.md b/docs/pr-batch-test-runtime.md index 078c591b..ae4b2204 100644 --- a/docs/pr-batch-test-runtime.md +++ b/docs/pr-batch-test-runtime.md @@ -66,8 +66,11 @@ For sub-path validation, the installed helper must support: - `--public-url` - `--web-base-path` -`scripts/deploy-test-runtime.sh` checks this before deployment and fails fast if the -HK helper is outdated. +The workflow checks this before building images. If the HK helper is outdated, +the workflow still bakes the requested web base path into the web image so +`/skillhub/runtime-config.js` and `/skillhub/api/...` routing can be validated. +However, update the helper before treating `SKILLHUB_PUBLIC_BASE_URL` and +`SKILLHUB_WEB_API_BASE_URL` as runtime-configured on the HK machine. ## Recommended usage diff --git a/scripts/deploy-test-runtime.sh b/scripts/deploy-test-runtime.sh index e1078285..f49c6375 100755 --- a/scripts/deploy-test-runtime.sh +++ b/scripts/deploy-test-runtime.sh @@ -187,26 +187,35 @@ if [[ -n "${web_base_path}" ]]; then normalized_web_base_path="$(normalize_base_path "${web_base_path}")" fi +helper_supports_sub_path=true if [[ -n "${public_url}" || -n "${web_base_path}" ]]; then helper_help="$(sudo /usr/local/bin/skillhub-test-deploy --help 2>&1 || true)" if ! grep -Fq -- "--public-url" <<<"${helper_help}" || \ ! grep -Fq -- "--web-base-path" <<<"${helper_help}"; then + helper_supports_sub_path=false echo "HK deploy helper is outdated: /usr/local/bin/skillhub-test-deploy" >&2 - echo "Install the current scripts/skillhub-test-deploy-remote.sh on the HK machine before sub-path validation." >&2 - echo "Required helper options: --public-url and --web-base-path" >&2 - exit 1 + echo "Falling back to a web image with the requested base path baked at build time." >&2 + echo "Update scripts/skillhub-test-deploy-remote.sh on the HK machine to let runtime env write SKILLHUB_PUBLIC_BASE_URL and SKILLHUB_WEB_API_BASE_URL." >&2 fi fi deploy_status=0 -sudo /usr/local/bin/skillhub-test-deploy \ - --deploy-tag "${deploy_tag}" \ - --immutable-tag "${immutable_tag}" \ - --merged-sha "${merged_sha}" \ - --pr-csv "${pr_csv}" \ - --run-url "${run_url}" \ - --public-url "${public_url}" \ - --web-base-path "${web_base_path}" || deploy_status=$? +deploy_args=( + --deploy-tag "${deploy_tag}" + --immutable-tag "${immutable_tag}" + --merged-sha "${merged_sha}" + --pr-csv "${pr_csv}" + --run-url "${run_url}" +) + +if [[ "${helper_supports_sub_path}" == "true" ]]; then + deploy_args+=( + --public-url "${public_url}" + --web-base-path "${web_base_path}" + ) +fi + +sudo /usr/local/bin/skillhub-test-deploy "${deploy_args[@]}" || deploy_status=$? web_health_paths=("/nginx-health") if [[ -n "${normalized_web_base_path}" && "${normalized_web_base_path}" != "/" ]]; then