🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(preview): pin the preview URL to the top of the PR description (#15588)
Trang Nguyeneac90bcba559
diff --git a/.agents/skills/langfuse-previews/SKILL.md b/.agents/skills/langfuse-previews/SKILL.mdindex 839720a848..dc2a409b2c 100644--- a/.agents/skills/langfuse-previews/SKILL.md+++ b/.agents/skills/langfuse-previews/SKILL.md@@ -32,9 +32,10 @@ Pushing updates it; closing the PR tears it down.## Using a preview- **Spin up** — open a same-repo PR. It's auto-labeled and builds (~5 min); a- bot comment then posts the preview URL and login, and a deployment in the- shared GitHub `PR Preview` environment gives the PR a **View deployment**- button. No manual step, no label to add.+ bot comment then posts the preview URL and login, a `Live preview:` line is+ pinned at the top of the PR description (removed again on teardown), and a+ deployment in the shared GitHub `PR Preview` environment gives the PR a+ **View deployment** button. No manual step, no label to add.- **Log in** — use the credentials in the **bot's PR comment** (the source oftruth). The demo project's shared seed identity is `[email protected]` /`password`, with API keys `pk-lf-1234567890` / `sk-lf-1234567890` — shared anddiff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.ymlindex e93f75f37c..43c33ffde1 100644--- a/.github/workflows/preview-build.yml+++ b/.github/workflows/preview-build.yml@@ -3,8 +3,9 @@ name: AWS preview build# Build the PR's web + worker images and push them to ECR as pr-<n>-<sha>.# The Argo CD ApplicationSet in the infrastructure repo deploys whichever image# tag exists for a labeled PR; this workflow only builds and pushes, then posts-# the preview URL on the PR — as the marker-tagged status comment and as a-# native GitHub deployment (the "View deployment" button). All PR deployments+# the preview URL on the PR — as the marker-tagged status comment, as a native+# GitHub deployment (the "View deployment" button), and as a machine-managed+# block pinned atop the PR description. All PR deployments# share one GitHub environment; Argo CD still owns the real preview lifecycle.## The two images are independent artifacts pushed to two independent ECR repos@@ -392,6 +393,61 @@ jobs:core.setFailed(`${failures} of ${previousDeployments.length} previous deployment(s) could not be deleted.`);}+ # Pin the preview URL to the very top of the PR description, where it+ # stays visible no matter how long the discussion below grows (GitHub has+ # no pinned comments for PRs). The block is machine-managed between+ # hidden markers; the author's own text below it is never touched. Runs+ # after the deployment record on purpose: a pin API failure still fails+ # the job loudly, but can no longer skip the more functional artifact.+ - name: Pin preview link to the PR description+ if: needs.build.result == 'success'+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0+ env:+ PREVIEW_HOST: ${{ needs.meta.outputs.preview_host }}+ with:+ script: |+ // Markers + regex must stay byte-identical to the removal snippets+ // in preview-deactivate.yml and preview-stale-cleanup.yml, or a+ // torn-down preview keeps advertising a dead URL at the top of+ // the PR forever.+ const START = "<!-- aws-preview-pin:start -->";+ const END = "<!-- aws-preview-pin:end -->";+ const { owner, repo } = context.repo;+ const pull_number = context.payload.pull_request.number;+ const host = process.env.PREVIEW_HOST;++ // Exactly one bold line, by request — the markdown link is needed+ // because a schemeless hostname does not auto-link.+ const block = [+ START,+ `🟡 **Live preview: [${host}](https://${host})**`,+ END,+ "",+ "",+ ].join("\n");++ // Sweep every existing block (line-anchored, so a block displaced+ // by a manual description edit can't duplicate or outlive the+ // preview; inline mentions of the markers mid-sentence are never+ // matched — only a full quoted block with markers on their own+ // lines would be swept), then prepend the fresh block at the top.+ // The (?:\r?\n)* tail matters: web-UI edits resubmit bodies with+ // CRLF endings. Last-writer-wins against a concurrent manual edit+ // is acceptable for one machine-managed line every build rewrites.+ const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });+ const body = pr.body ?? "";+ const strayRe = new RegExp(`(^|\\r?\\n)(?:${START}[\\s\\S]*?${END}(?:\\r?\\n)*)+`, "g");+ const next = block + body.replace(strayRe, "$1").replace(/^(?:\r?\n)+/, "");+ if (next.length > 65536) {+ // Degrade to a warning: a huge description should not fail+ // preview builds (a real API failure below still fails loudly).+ core.warning("PR body would exceed GitHub's 65536-char limit; leaving it unchanged.");+ return;+ }+ if (next !== body) {+ await github.rest.pulls.update({ owner, repo, pull_number, body: next });+ }+# Two distinct failure paths, each keyed on `== 'failure'` (NOT# `!= 'success'`): that keeps them from firing on `cancelled` (a# superseding push cancels the run via cancel-in-progress, and always()