🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
ci(workbench): upload a preview version per PR instead of a dry run (#18592)
Innei2d6de140945b
diff --git a/.github/workflows/verify-workbench.yml b/.github/workflows/verify-workbench.ymlindex e73c3facd26..40e254681b5 100644--- a/.github/workflows/verify-workbench.yml+++ b/.github/workflows/verify-workbench.yml@@ -6,6 +6,7 @@ on:permissions:actions: readcontents: read+ pull-requests: writeconcurrency:group: verify-workbench-${{ github.event.pull_request.number }}@@ -66,18 +67,76 @@ jobs:- name: Build workbenchif: steps.detect.outputs.should_build == 'true'- run: bun run build:rr+ env:+ # NODE_ENV is load-bearing: vite.config.rr.mts takes its dev branch otherwise and+ # discards VITE_CDN_BASE without failing. A preview serves its own assets from its+ # own workers.dev origin, the way production serves them from the CDN — never+ # same-origin, because the gateway routes /assets to the landing target. Empty on+ # fork PRs, which have no secrets to upload with and only run the size guard.+ NODE_ENV: production+ NODE_OPTIONS: --max-old-space-size=8192+ VITE_CDN_BASE: >-+ ${{ github.event.pull_request.head.repo.full_name == github.repository+ && format('https://pr{0}-lobehub-workbench.lobeobjects-tg.workers.dev/', github.event.pull_request.number)+ || '' }}+ run: |+ bun run build:rr+ printf '/*\n Access-Control-Allow-Origin: *\n' > build/client/_headersworking-directory: apps/workbench- - name: Validate worker bundle+ - name: Upload preview version and validate worker bundleif: steps.detect.outputs.should_build == 'true'+ # Explicit `bash` rather than the default shell, whose lack of pipefail would let a+ # wrangler failure pass as a green step through the `tee`.+ shell: bash+ env:+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_PREVIEW_API_TOKEN || secrets.CLOUDFLARE_API_TOKEN }}+ SAME_REPO: ${{ github.event.pull_request.head.repo.full_name == github.repository }}+ PR: ${{ github.event.pull_request.number }}run: |- node_modules/.bin/wrangler deploy --dry-run \- --config build/server/wrangler.json | tee /tmp/dry-run.log- gzip_kib=$(grep -Eo 'gzip: [0-9.]+ KiB' /tmp/dry-run.log | grep -Eo '[0-9.]+' | head -1)+ if [ "$SAME_REPO" = 'true' ]; then+ set -- --preview-alias "pr${PR}" --message "PR-${PR}"+ else+ set -- --dry-run+ fi+ node_modules/.bin/wrangler versions upload \+ --config build/server/wrangler.json "$@" | tee /tmp/upload.log+ gzip_kib=$(grep -Eo 'gzip: [0-9.]+ KiB' /tmp/upload.log | grep -Eo '[0-9.]+' | head -1)echo "worker gzip size: ${gzip_kib} KiB"if [ -n "$gzip_kib" ] && [ "$(printf '%.0f' "$gzip_kib")" -gt 8192 ]; thenecho "::error::worker bundle ${gzip_kib} KiB gzip exceeds the 8 MiB guard (plan limit is 10 MiB)"exit 1fi+ if [ "$SAME_REPO" = 'true' ]; then+ echo "Preview: https://pr${PR}-lobehub-workbench.lobeobjects-tg.workers.dev" >> "$GITHUB_STEP_SUMMARY"+ fiworking-directory: apps/workbench++ - name: Comment the preview URL+ if: steps.detect.outputs.should_build == 'true' && github.event.pull_request.head.repo.full_name == github.repository+ shell: bash+ env:+ GH_TOKEN: ${{ github.token }}+ PR: ${{ github.event.pull_request.number }}+ REPO: ${{ github.repository }}+ run: |+ # Matched on a marker rather than `gh pr comment --edit-last`, which edits the+ # last comment by this actor — and other workflows in this repo comment as the+ # same bot, so it would rewrite one of theirs.+ marker='<!-- workbench-preview -->'+ body="${marker}+ ### Workbench preview++ <https://pr${PR}-lobehub-workbench.lobeobjects-tg.workers.dev>++ A version, not a deployment: it takes no production traffic. Assets are served+ from that same origin, so the page also renders through the gateway — point+ \`workbench\`'s override at that host on staging in 鳥居番, then open+ <https://gateway-staging.lobehub.com/acceptance>."+ id=$(gh api "repos/${REPO}/issues/${PR}/comments" --paginate \+ --jq "map(select(.body | startswith(\"${marker}\"))) | .[0].id // empty")+ if [ -n "$id" ]; then+ gh api -X PATCH "repos/${REPO}/issues/comments/${id}" -f body="$body" > /dev/null+ else+ gh api -X POST "repos/${REPO}/issues/${PR}/comments" -f body="$body" > /dev/null+ fi