@@ -23,7 +23,9 @@ import {
23
23
startApplicationByUuid ,
24
24
startServiceByUuid ,
25
25
updateEnvsByServiceUuid ,
26
- updateServiceByUuid
26
+ updateServiceByUuid ,
27
+ updateApplicationByUuid ,
28
+ deployByTagOrUuid
27
29
} from './client/sdk.gen.js'
28
30
import { TCPTunnelClient } from './tcp-tunnel.js'
29
31
@@ -220,10 +222,13 @@ export default class Coolify {
220
222
( service ) => service . name === supabaseComponentName
221
223
)
222
224
let backendServiceUUID : string
225
+ let isNewSupabaseService : boolean = false
223
226
let createdNewSupabaseService : boolean = false
224
227
if ( existingSupabaseService && existingSupabaseService . uuid ) {
225
228
backendServiceUUID = existingSupabaseService . uuid
229
+ isNewSupabaseService = false
226
230
} else {
231
+ isNewSupabaseService = true
227
232
console . log ( `Creating new supabase service ${ supabaseComponentName } ` )
228
233
createdNewSupabaseService = true
229
234
const updatedDockerCompose = await readFile (
@@ -369,7 +374,8 @@ export default class Coolify {
369
374
supabase_url,
370
375
supabase_anon_key,
371
376
supabase_service_role_key,
372
- deploymentKey
377
+ deploymentKey,
378
+ isNewSupabaseService
373
379
}
374
380
}
375
381
async cleanup ( {
@@ -435,7 +441,8 @@ export default class Coolify {
435
441
supabase_url,
436
442
supabase_anon_key,
437
443
supabase_service_role_key,
438
- deploymentKey
444
+ deploymentKey,
445
+ isNewSupabaseService
439
446
} = await this . getSupabaseServiceUUIDOrCreateNewOne ( {
440
447
supabaseComponentName,
441
448
ephemeral
@@ -469,15 +476,15 @@ export default class Coolify {
469
476
serviceUUID : backendServiceUUID ,
470
477
deployToken : deploymentKey ,
471
478
checkedOutProjectDir,
472
- resetDb : true ,
479
+ resetDb : isNewSupabaseService ,
473
480
postgresPassword : postgres_password
474
481
} )
475
482
476
483
const existingFrontendApp = existingApplications . data ?. find (
477
484
( app ) => app . name === frontendAppName
478
485
)
479
486
let appUUID = existingFrontendApp ?. uuid
480
- if ( ! existingFrontendApp ) {
487
+ if ( ! existingFrontendApp || ! appUUID ) {
481
488
//Create frontend service, deploy it
482
489
const frontendApp = await createPrivateGithubAppApplication ( {
483
490
client : this . client ,
@@ -553,6 +560,29 @@ export default class Coolify {
553
560
appUUID : appUUID
554
561
} )
555
562
console . log ( 'Frontend started' )
563
+ } else {
564
+ //Update the commit SHA of the frontend app
565
+ await updateApplicationByUuid ( {
566
+ client : this . client ,
567
+ path : {
568
+ uuid : appUUID
569
+ } ,
570
+ body : {
571
+ git_commit_sha : gitCommitSha
572
+ }
573
+ } )
574
+ console . log (
575
+ `Deploying frontend app ${ appUUID } with commit ${ gitCommitSha } `
576
+ )
577
+ await deployByTagOrUuid ( {
578
+ client : this . client ,
579
+ query : {
580
+ uuid : appUUID
581
+ }
582
+ } )
583
+ await this . waitUntilServiceOrAppisReady ( {
584
+ appUUID : appUUID
585
+ } )
556
586
}
557
587
558
588
return {
0 commit comments