Skip to content

Commit a63c85e

Browse files
authored
Merge pull request #414 from kagent-dev/kkb-cloudflare-deploy-fix
fix(ci): stop PR previews from deploying to production
2 parents 7a9f5b7 + 41b3a29 commit a63c85e

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

.github/workflows/preview.yaml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

src/app/docs/kagent/examples/slack-a2a/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ You'll be redirected to the app's basic information page. Next, we need to give
5050
1. Click the OAuth & Permissions tab from the left sidebar.
5151
2. Scroll down to the "Scopes" section.
5252
3. Click "Add an OAuth Scope" in the "Bot Token Scopes" section.
53-
4. From the dropdown menu add the the following scopes (you can add more scopes if you want to experiment with other features):
53+
4. From the dropdown menu add the following scopes (you can add more scopes if you want to experiment with other features):
5454
- `chat:write`
5555
- `commands`
5656

wrangler.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ compatibility_date = "2024-09-23"
44
compatibility_flags = ["nodejs_compat"]
55

66
main = ".open-next/worker.js"
7-
assets = { directory = ".open-next/assets", binding = "ASSETS" }
7+
assets = { directory = ".open-next/assets", binding = "ASSETS" }
8+
9+
# Enable per-version preview URLs so PR builds (`wrangler versions upload` in
10+
# preview.yaml) get a shareable URL without deploying to production.
11+
preview_urls = true

0 commit comments

Comments
 (0)