Skip to content
This repository was archived by the owner on Nov 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/alchemy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
# The stage, as https://alchemy.run/environments/ci names it: `pr-<number>` 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:
Expand Down Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions alchemy.run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 }),
},
Expand Down Expand Up @@ -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 };
}),
);
Loading