add backend publication ext
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package ru.shadowsparky
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
|
||||
fun Project.setupBackendPublication() {
|
||||
val switchToRemoteContext = tasks.register("switchToRemoteContext", Exec::class.java) {
|
||||
group = "publishing"
|
||||
description = "Переключает Docker-контекст на remote"
|
||||
commandLine("docker", "context", "use", "remote")
|
||||
}
|
||||
val switchToDefaultContext = tasks.register("switchToDefaultContext",Exec::class.java) {
|
||||
group = "publishing"
|
||||
description = "Возвращает Docker-контекст на default"
|
||||
commandLine("docker", "context", "use", "default")
|
||||
}
|
||||
tasks.register("publishImageRemote") {
|
||||
group = "publishing"
|
||||
description = "Публикует Docker image через remote context"
|
||||
dependsOn(
|
||||
switchToRemoteContext,
|
||||
"publishImageToLocalRegistry"
|
||||
)
|
||||
finalizedBy(switchToDefaultContext)
|
||||
}
|
||||
tasks.register("publishImageLocal") {
|
||||
group = "publishing"
|
||||
description = "Публикует Docker image"
|
||||
dependsOn("publishImageToLocalRegistry")
|
||||
}
|
||||
tasks.named("publishImageToLocalRegistry") {
|
||||
mustRunAfter(switchToRemoteContext)
|
||||
}
|
||||
switchToDefaultContext {
|
||||
mustRunAfter("publishImageToLocalRegistry")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user