11import 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" ;
83import { GitHubSecret , RepositoryEnvironment } from "alchemy/github" ;
94import { CloudflareStateStore } from "alchemy/state" ;
105import { config } from "dotenv" ;
@@ -71,10 +66,12 @@ const alchemyStateToken = requireValue(
7166
7267const db = await D1Database ( "database" , {
7368 migrationsDir : "../../packages/db/src/migrations" ,
69+ adopt : true ,
7470} ) ;
7571
7672export 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