Skip to content

Commit a192169

Browse files
committed
fix paths
1 parent 7090bca commit a192169

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
deployment_app_uuid:
1414
description:
1515
The UUID of the Coolify GitHub app to use for generating deployments
16-
required: false
16+
required: true
1717
base_deployment_url:
1818
description:
1919
The base URL to deploy the web application to. This is used to generate

dist/index.js

Lines changed: 19 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/coolify.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { exec } from '@actions/exec'
22
import { randomBytes } from 'crypto'
33
import { readdir, readFile, stat } from 'fs/promises'
44
import JSZip from 'jszip'
5-
import { join, relative } from 'path'
5+
import path, { join, relative } from 'path'
66
import postgres from 'postgres'
77

88
import { createClient } from './client/client/client.js'
@@ -132,11 +132,24 @@ export default class Coolify {
132132
timeout_seconds?: number
133133
}) {
134134
const client = this.client
135+
if (serviceUUID) {
136+
console.log(`Waiting for service ${serviceUUID} to be ready`)
137+
} else if (appUUID) {
138+
console.log(`Waiting for app ${appUUID} to be ready`)
139+
} else {
140+
throw new Error('No service or app UUID provided')
141+
}
135142
return new Promise((resolve, reject) => {
136143
const timeout = timeout_seconds ?? 600
137144
const expirationTimeout = setTimeout(() => {
138145
clearInterval(interval)
139-
reject(new Error('Timeout waiting for service or app to be ready'))
146+
reject(
147+
new Error(
148+
serviceUUID
149+
? `Timeout waiting for service ${serviceUUID} to be ready`
150+
: `Timeout waiting for app ${appUUID} to be ready`
151+
)
152+
)
140153
}, timeout * 1000)
141154
async function checkStatus() {
142155
if (serviceUUID) {
@@ -147,8 +160,6 @@ export default class Coolify {
147160
}
148161
})
149162
if (serviceStatus.data && 'status' in serviceStatus.data) {
150-
console.log('Service status:')
151-
console.log(serviceStatus.data['status'])
152163
if (serviceStatus.data['status'] === 'running:healthy') {
153164
clearInterval(interval)
154165
clearTimeout(expirationTimeout)
@@ -191,6 +202,7 @@ export default class Coolify {
191202

192203
private async getServerUUID() {
193204
const servers = await listServers({ client: this.client })
205+
console.log(servers)
194206
if (!servers.data || servers.data.length === 0 || !servers.data[0].uuid) {
195207
throw new Error('No servers found')
196208
}
@@ -215,7 +227,11 @@ export default class Coolify {
215227
console.log(`Creating new supabase service ${supabaseComponentName}`)
216228
createdNewSupabaseService = true
217229
const updatedDockerCompose = await readFile(
218-
'./supabase-pawtograder.yml',
230+
path.join(
231+
path.dirname(new URL(import.meta.url).pathname),
232+
'../',
233+
'supabase-pawtograder.yml'
234+
),
219235
'utf-8'
220236
)
221237
//Create backend service
@@ -414,7 +430,7 @@ export default class Coolify {
414430
await this.pushMigrations({
415431
serviceUUID: backendServiceUUID,
416432
deployToken: deploymentKey,
417-
checkedOutSupabaseDir: checkedOutProjectDir,
433+
checkedOutProjectDir,
418434
resetDb: true,
419435
postgresPassword: postgres_password
420436
})
@@ -514,13 +530,13 @@ export default class Coolify {
514530
async pushMigrations({
515531
serviceUUID,
516532
deployToken,
517-
checkedOutSupabaseDir,
533+
checkedOutProjectDir,
518534
postgresPassword,
519535
resetDb
520536
}: {
521537
serviceUUID: string
522538
deployToken: string
523-
checkedOutSupabaseDir: string
539+
checkedOutProjectDir: string
524540
postgresPassword: string
525541
resetDb?: boolean
526542
}) {
@@ -535,7 +551,7 @@ export default class Coolify {
535551
console.log('Tunnel connected')
536552
let command = ''
537553
if (!resetDb)
538-
command = `supabase db push --include-all --db-url postgres://postgres:${postgresPassword}@localhost:${localPort}/postgres`
554+
command = `./node_modules/.bin/supabase db push --include-all --db-url postgres://postgres:${postgresPassword}@localhost:${localPort}/postgres`
539555
else {
540556
const sql = postgres(
541557
`postgres://postgres:${postgresPassword}@localhost:${localPort}/postgres`
@@ -544,10 +560,10 @@ export default class Coolify {
544560
await sql`TRUNCATE TABLE storage.objects CASCADE`
545561
await sql`TRUNCATE TABLE vault.secrets CASCADE`
546562
await sql.end()
547-
command = `supabase db reset --db-url postgres://postgres:${postgresPassword}@localhost:${localPort}/postgres`
563+
command = `./node_modules/.bin/supabase db reset --db-url postgres://postgres:${postgresPassword}@localhost:${localPort}/postgres`
548564
}
549565
await exec(command, undefined, {
550-
cwd: checkedOutSupabaseDir,
566+
cwd: checkedOutProjectDir,
551567
input: Buffer.from('y')
552568
})
553569
console.log('Migrations pushed')

0 commit comments

Comments
 (0)