@@ -24,15 +24,43 @@ jobs:
2424 - name : Build the site
2525 run : npm run build:worker
2626
27+ # Derive a stable preview alias from the PR branch name. Cloudflare preview
28+ # aliases must be a valid subdomain label (lowercase alphanumerics and
29+ # hyphens), and `<alias>-<worker>` must stay under the 63-char DNS limit, so
30+ # sanitize and cap the length.
31+ - name : Compute preview alias from branch name
32+ id : alias
33+ run : |
34+ alias=$(echo "${{ github.head_ref }}" \
35+ | tr '[:upper:]' '[:lower:]' \
36+ | sed 's/[^a-z0-9-]/-/g; s/-\{2,\}/-/g; s/^-*//; s/-*$//' \
37+ | cut -c1-40)
38+ echo "alias=$alias" >> "$GITHUB_OUTPUT"
39+ echo "Preview alias: $alias"
40+
2741 - name : Create website preview
2842 id : deploy
2943 uses : cloudflare/wrangler-action@v3.14.1
3044 with :
3145 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
3246 accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
33- command : deploy --minify
47+ # Upload a new Worker version and get a preview URL WITHOUT shifting
48+ # production traffic. `deploy` promotes the version to 100% live, so PR
49+ # runs were redeploying prod. `versions upload` keeps prod on the
50+ # currently-deployed version; production is deployed only by
51+ # production.yaml (on merge to main).
52+ #
53+ # --preview-alias gives a STABLE, branch-named preview URL
54+ # (<alias>-<worker>.<subdomain>.workers.dev) that updates in place on
55+ # each push, instead of a new per-version hostname every time.
56+ command : versions upload --minify --preview-alias ${{ steps.alias.outputs.alias }}
3457
35- - name : Print website URL
58+ - name : Print website URLs
3659 env :
37- DEPLOYMENT_URL : ${{ steps.deploy.outputs.deployment-url }}
38- run : echo $DEPLOYMENT_URL
60+ # Per-version URL (changes each push) from the wrangler-action output;
61+ # stable alias URL built from the branch alias + fixed worker/subdomain.
62+ VERSION_URL : ${{ steps.deploy.outputs.deployment-url }}
63+ ALIAS : ${{ steps.alias.outputs.alias }}
64+ run : |
65+ echo "Version Preview URL: ${VERSION_URL}"
66+ echo "Version Preview Alias URL: https://${ALIAS}-kagent-website.solo-io.workers.dev"
0 commit comments