From f04caabb375059834e195b1479dc803f553673d5 Mon Sep 17 00:00:00 2001 From: Nicu Chiciuc Date: Sat, 31 Oct 2026 18:58:36 +0200 Subject: [PATCH] Show the stacks in one pull request comment The step alchemy-convex stack-comment replaces the GitHub.Comment of the stack. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/alchemy.yml | 8 ++++++-- alchemy.run.ts | 13 +------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/alchemy.yml b/.github/workflows/alchemy.yml index 3e728f3..120f5bd 100644 --- a/.github/workflows/alchemy.yml +++ b/.github/workflows/alchemy.yml @@ -26,8 +26,6 @@ jobs: # The stage, as https://alchemy.run/environments/ci names it: `pr-` for a pull # request, `prod` on main, and the branch name otherwise, where no step below deploys. STAGE: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || (github.ref == 'refs/heads/main' && 'prod' || github.ref_name) }} - # GitHub.GitHubEnv in alchemy.run.ts reads it for the preview comment. Empty on a push. - PULL_REQUEST: ${{ github.event.pull_request.number }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -72,6 +70,12 @@ jobs: env: CONVEX_ACCESS_TOKEN: ${{ secrets.CONVEX_ACCESS_TOKEN }} GITHUB_TOKEN: ${{ github.token }} + - name: Update the stack comment + if: steps.keys.outputs.skip != 'true' && github.event_name == 'pull_request' && github.event.action != 'closed' + run: pnpm exec alchemy-convex stack-comment + env: + CONVEX_ACCESS_TOKEN: ${{ secrets.CONVEX_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} - name: Destroy the preview if: steps.keys.outputs.skip != 'true' && github.event.action == 'closed' run: pnpm exec alchemy destroy --stage "$STAGE" --yes --no-input diff --git a/alchemy.run.ts b/alchemy.run.ts index 73acd69..2cc791d 100644 --- a/alchemy.run.ts +++ b/alchemy.run.ts @@ -13,7 +13,6 @@ import { execFileSync } from "node:child_process"; import * as GitHub from "@alchemy.run/github"; import * as Convex from "@samebase/alchemy-convex"; import * as Alchemy from "alchemy"; -import * as Output from "alchemy/Output"; import * as RemovalPolicy from "alchemy/RemovalPolicy"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; @@ -34,6 +33,7 @@ if (repository === undefined) { export default Alchemy.Stack( repository, { + // The GitHub provider has no resource here: it forgets the PreviewComment rows of older previews. providers: Layer.mergeAll(GitHub.providers(), Convex.providers()), state: Convex.state({ team }), }, @@ -64,17 +64,6 @@ export default Alchemy.Stack( source, }).pipe(RemovalPolicy.destroy()); - const github = yield* GitHub.GitHubEnv; - if (github?.pr) { - // Retained: a closed pull request keeps the comment, as a record of what was deployed; the - // preview's URL stops answering when the stage is destroyed. - yield* GitHub.Comment("PreviewComment", { - owner: github.owner, - repository: github.repository, - issueNumber: github.pr, - body: Output.interpolate`Preview \`${stage}\`: ${deployment.siteUrl}`, - }).pipe(RemovalPolicy.retain()); - } return { url: deployment.siteUrl }; }), );