Skip to content

Commit 4297f37

Browse files
committed
add logs
1 parent 8e93db8 commit 4297f37

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/main/kotlin/Main.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.klahap.fraploy
22

33
import io.github.klahap.fraploy.model.FraployConfig
44
import io.github.klahap.fraploy.service.FraployService
5+
import kotlin.system.exitProcess
56
import kotlin.time.Duration.Companion.seconds
67

78

@@ -13,11 +14,13 @@ suspend fun main() {
1314
}
1415
source {
1516
releaseGroupTitle = System.getenv("FRAPPE_CLOUD_RELEASE_GROUP_TITLE")
16-
addAppUpdate(appName = "frappe", version = "v15.37.0")
17+
addAppUpdate(appName = "frappe", version = "v15.38.0")
1718
}
1819
blocking {
20+
enable = true
1921
pollDelay = 5.seconds
2022
}
2123
}.build()
2224
FraployService.run(config)
25+
exitProcess(0)
2326
}

src/main/kotlin/service/FraployService.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,31 @@ class FraployService(
1111
) {
1212
private val frappeCloudService = FrappeCloudService(client = client, credentials = credentials)
1313

14-
suspend fun update(source: FraployConfig.Source): DeployName {
14+
suspend fun update(source: FraployConfig.Source): DeployName? {
1515
val releaseGroupName = frappeCloudService.getReleaseGroupName(source.releaseGroupTitle)
1616
val apps = frappeCloudService.getReleaseGroup(releaseGroupName)
1717
val sites = frappeCloudService.getSites(releaseGroupName)
1818

1919
val appUpdates = apps.getUpdates(source.updateRequests)
2020
val siteUpdates = sites.map { it.toUpdate() }.toSet()
2121

22+
if (appUpdates.isEmpty()) {
23+
println("all apps are already up-to-date. No deployment necessary.")
24+
return null
25+
} else {
26+
println("App updates:")
27+
val maxAppNameLength = appUpdates.maxOf { it.app.name.length }
28+
appUpdates.forEach { println("${it.app.name.padStart(maxAppNameLength + 4)} -> ${it.hash}") }
29+
println()
30+
}
31+
32+
println("Sites at $releaseGroupName (${source.releaseGroupTitle}):")
33+
if (siteUpdates.isEmpty())
34+
println("<no-sites>")
35+
else
36+
siteUpdates.forEach { println(" ${it.name}") }
37+
println()
38+
2239
val deployName = frappeCloudService.deployAndUpdate(
2340
releaseGroupName = releaseGroupName,
2441
apps = appUpdates,
@@ -66,7 +83,7 @@ class FraployService(
6683

6784
suspend fun run(config: FraployConfig) {
6885
val service = FraployService(credentials = config.credentials)
69-
val deployName = service.update(source = config.source)
86+
val deployName = service.update(source = config.source) ?: return
7087
service.blocking(deployName = deployName, blockingConfig = config.blocking)
7188
}
7289
}

0 commit comments

Comments
 (0)