Skip to content

Commit

Permalink
Added settings for cache customization, fixed readme to use new names…
Browse files Browse the repository at this point in the history
…pace.
  • Loading branch information
nigelgbanks committed Dec 5, 2022
1 parent f7cad7b commit 0198565
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ To include this plugin for versions 0.11+ add the following to your `build.gradl

```kotlin
plugins {
id("com.github.nigelgbanks.IsleDocker") version "0.11"
id("io.github.nigelgbanks.Isle") version "1.0.1"
}
```

Expand All @@ -153,14 +153,14 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath("com.github.nigelgbanks:isle-gradle-docker-plugin") {
classpath("io.github.nigelgbanks:isle-gradle-docker-plugin") {
version {
branch = "BRANCH_NAME"
}
}
}
}
apply(plugin = "com.github.nigelgbanks.IsleDocker")
apply(plugin = "io.github.nigelgbanks.Isle")
```

Note that it will only use **committed** changes.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.0"
version = "1.0.1"
group = "io.github.nigelgbanks"

repositories {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# suppress inspection "UnusedProperty" for whole file
org.gradle.parallel=true
org.gradle.caching=true
version=1.0-SNAPSHOT
version=1.0.1-SNAPSHOT
20 changes: 12 additions & 8 deletions src/main/kotlin/plugins/BuildCtlPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.*
import plugins.BuildKitPlugin.Companion.buildKitCacheRepository
import plugins.BuildKitPlugin.Companion.buildKitCacheTag
import plugins.BuildKitPlugin.Companion.buildKitPlatforms
import plugins.BuildKitPlugin.Companion.buildKitRepository
import plugins.BuildKitPlugin.Companion.buildKitTag
Expand Down Expand Up @@ -157,23 +159,25 @@ class BuildCtlPlugin : Plugin<Project> {
}
additionalArguments.addAll(
listOf(
"--import-cache", "type=registry,ref=islandora/${project.name}:cache",
)
"--import-cache", "type=registry,ref=${project.buildKitCacheRepository}/${project.name}:${project.buildKitCacheTag}",
)
)
// Use GitHub action cache if available.
if (System.getenv("GITHUB_ACTIONS") == "true") {
additionalArguments.addAll(
listOf(
"--export-cache", "type=gha",
"--import-cache", "type=gha",
)
)
if (System.getenv("GITHUB_REF_NAME") == "main") {
additionalArguments.addAll(
listOf(
"--export-cache", "type=registry,mode=max,compression=estargz,ref=islandora/${project.name}:cache",
)
}
// Only update the cache image when building the main branch.
if (System.getenv("GITHUB_REF_NAME") == "main") {
additionalArguments.addAll(
listOf(
"--export-cache", "type=registry,mode=max,compression=estargz,ref=${project.buildKitCacheRepository}/${project.name}:${project.buildKitCacheTag}",
)
}
)
}
images.get().joinToString(",").let {
additionalArguments.addAll(
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/plugins/BuildKitPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class BuildKitPlugin : Plugin<Project> {
val Project.buildKitTag: String
get() = properties.getOrDefault("buildkit.build-arg.tag", "latest") as String

// The repository to push/pull image cache to/from.
val Project.buildKitCacheRepository: String
get() = properties.getOrDefault("buildkit.cache.repository", "islandora") as String

// The repository to push/pull image cache to/from.
val Project.buildKitCacheTag: String
get() = properties.getOrDefault("buildkit.cache.tag", "cache") as String

val Project.buildKitContainer: String
get() = properties.getOrDefault("buildkit.container", "isle-buildkit") as String

Expand Down

0 comments on commit 0198565

Please sign in to comment.