use cache

This commit is contained in:
Elio Bischof
2025-06-17 11:07:51 +02:00
parent 1977665ce6
commit dcadc54263
2 changed files with 5 additions and 6 deletions

View File

@@ -22,15 +22,14 @@ jobs:
type=semver,pattern={{version}} type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}} type=semver,pattern={{major}}
labels: |
git-branch={{branch}}
- name: Set up persistent Buildx builder - name: Set up persistent Buildx builder
id: buildx id: buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build - name: Build
uses: docker/bake-action@v6 uses: docker/bake-action@v6
env: env:
GIT_BRANCH: ${{ fromJSON(steps.meta.outputs.json).labels['git-branch'] }} # latest if branch is main, otherwise image version which is the pull request number
BUILD_CACHE_KEY: "${{ github.ref == 'refs/heads/main' ? "latest" : fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}"
with: with:
source: . source: .
push: false push: false

View File

@@ -4,7 +4,7 @@ variable "IMAGE_REGISTRY" {
default = "ghcr.io/zitadel" default = "ghcr.io/zitadel"
} }
variable "GIT_BRANCH" { variable "BUILD_CACHE_KEY" {
default = "local" default = "local"
} }
@@ -28,10 +28,10 @@ target "login-lint" {
login-dev-base = "target:login-dev-base" login-dev-base = "target:login-dev-base"
} }
cache-from = [ cache-from = [
"type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:${GIT_BRANCH}", "type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:${BUILD_CACHE_KEY}",
"type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:main" "type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:main"
] ]
cache-to = ["type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:${GIT_BRANCH},mode=max"] cache-to = ["type=registry,ref=${IMAGE_REGISTRY}/login-lint-buildcache:${BUILD_CACHE_KEY},mode=max"]
} }
variable "LOGIN_TEST_UNIT_TAG" { variable "LOGIN_TEST_UNIT_TAG" {