Skip to content

Commit dd48bea

Browse files
committed
fix: remove unused AccountApiToken, add adopt:true to all resources
1 parent 85c5d9f commit dd48bea

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
ALCHEMY_PASSWORD: ${{ secrets.ALCHEMY_PASSWORD }}
4343
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}
4444
BETTER_AUTH_SECRET: ${{ secrets.BETTER_AUTH_SECRET }}
45-
GITHUB_CLIENT_SECRET: ${{ secrets.GITHUB_CLIENT_SECRET }}
45+
GITHUB_CLIENT_SECRET: ${{ secrets.GH_CLIENT_SECRET }}
4646
GITHUB_CLIENT_ID: ${{ vars.GITHUB_CLIENT_ID }}
4747
run: bun alchemy deploy --stage ${{ env.STAGE }}

packages/infra/alchemy.run.ts

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import alchemy from "alchemy";
2-
import {
3-
AccountApiToken,
4-
D1Database,
5-
TanStackStart,
6-
Worker,
7-
} from "alchemy/cloudflare";
2+
import { D1Database, TanStackStart, Worker } from "alchemy/cloudflare";
83
import { GitHubSecret, RepositoryEnvironment } from "alchemy/github";
94
import { CloudflareStateStore } from "alchemy/state";
105
import { config } from "dotenv";
@@ -71,10 +66,12 @@ const alchemyStateToken = requireValue(
7166

7267
const db = await D1Database("database", {
7368
migrationsDir: "../../packages/db/src/migrations",
69+
adopt: true,
7470
});
7571

7672
export const web = await TanStackStart("web", {
7773
cwd: "../../apps/web",
74+
adopt: true,
7875
domains: webDomain ? [webDomain] : undefined,
7976
bindings: {
8077
VITE_SERVER_URL: viteServerUrl,
@@ -89,6 +86,7 @@ export const server = await Worker("server", {
8986
cwd: "../../apps/server",
9087
entrypoint: "src/index.ts",
9188
compatibility: "node",
89+
adopt: true,
9290
domains: apiDomain ? [apiDomain] : undefined,
9391
bindings: {
9492
DB: db,
@@ -123,33 +121,13 @@ if (isProd || isDev) {
123121
});
124122

125123
// Create scoped Cloudflare API token for CI
126-
const cfToken = await AccountApiToken(`cf-token-${stage}`, {
127-
name: `bs-shame-${stage}-deploy`,
128-
policies: [
129-
{
130-
effect: "allow",
131-
resources: { "com.cloudflare.api.account.*": "*" },
132-
permissionGroups: [
133-
"Workers Scripts Write",
134-
"Workers Routes Write",
135-
"D1 Write",
136-
"Account Settings Read",
137-
],
138-
},
139-
{
140-
effect: "allow",
141-
resources: { "com.cloudflare.api.account.zone.*": "*" },
142-
permissionGroups: ["Zone Read", "DNS Write"],
143-
},
144-
],
145-
});
146-
147124
// Push secrets to GitHub environment
125+
// Using existing CLOUDFLARE_API_TOKEN instead of minting new AccountApiToken
148126
await GitHubSecret(`gh-secret-cf-token-${stage}`, {
149127
owner,
150128
repository,
151129
name: "CLOUDFLARE_API_TOKEN",
152-
value: cfToken.value!,
130+
value: alchemy.secret(process.env.CLOUDFLARE_API_TOKEN!),
153131
environment: envName,
154132
});
155133

@@ -180,8 +158,8 @@ if (isProd || isDev) {
180158
await GitHubSecret(`gh-secret-gh-client-secret-${stage}`, {
181159
owner,
182160
repository,
183-
name: "GITHUB_CLIENT_SECRET",
184-
value: githubClientSecret,
161+
name: "GH_CLIENT_SECRET",
162+
value: alchemy.secret(process.env.GITHUB_CLIENT_SECRET!),
185163
environment: envName,
186164
});
187165

0 commit comments

Comments
 (0)