From 1d44a3c6bccd3a87918d3fd1003b7b734c2198dc Mon Sep 17 00:00:00 2001 From: tiye Date: Sun, 4 Oct 2026 13:21:53 +0800 Subject: [PATCH] fix: isolate COS preview assets by PR and run --- .github/workflows/upload.yaml | 6 ++++-- README.md | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index f46bff6..8854d90 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -57,11 +57,13 @@ jobs: - name: Select frontend CDN path id: asset-path + env: + PR_NUMBER: ${{ github.event.pull_request.number }} run: | set -euo pipefail asset_prefix="${GITHUB_REPOSITORY}/" if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then - asset_prefix="${GITHUB_REPOSITORY}/pr/" + asset_prefix="${GITHUB_REPOSITORY}/pr/${PR_NUMBER}/${GITHUB_RUN_ID}/${GITHUB_RUN_ATTEMPT}/" fi base_url="https://cos-sh.tiye.me/${asset_prefix}" echo "VITE_BASE_URL=${base_url}" >> "$GITHUB_ENV" @@ -85,7 +87,7 @@ jobs: needs: test runs-on: ubuntu-24.04 concurrency: - group: cos-${{ github.repository }}-${{ github.event_name == 'pull_request' && 'pr' || 'production' }} + group: cos-${{ github.repository }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'production' }} cancel-in-progress: false queue: max steps: diff --git a/README.md b/README.md index 6529a35..da664b4 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ The browser app uses typed Reel state, one Enum per dispatch, and validates legacy Map/new Store data when hydrating the original `map.clj.im` storage key. `VITE_BASE_URL` controls asset URLs (default `./`). CI builds against -`https://cos-sh.tiye.me/clojure-china/map.clojure-china.org/`, with `/pr/` for -previews. COS uploads only `dist/`; cos-upload-action v1.2.0 verifies public +`https://cos-sh.tiye.me/clojure-china/map.clojure-china.org/`, with +`/pr////` for isolated previews. Upload queues are separate +per PR; the production path is unchanged. COS uploads only `dist/`; cos-upload-action v1.2.0 verifies public uploads internally. Configure `COS_BUCKET`, `COS_SECRET_ID`, `COS_SECRET_KEY` in repository secrets. PRs without secrets run checks/build but skip upload verification; they do not demonstrate successful remote deployment.