Use Docker bake to build targets

This commit is contained in:
2025-11-16 20:21:58 +01:00
parent d4842f1cda
commit ef78704b98

View File

@@ -14,9 +14,8 @@ on:
description: Webhook to call after build is completed description: Webhook to call after build is completed
type: string type: string
outputs: outputs:
digest: images:
description: Digest of the build docker container value: ${{ jobs.build.outputs.images }}
value: ${{ jobs.build.outputs.digest }}
env: env:
OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}} OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}}
@@ -26,7 +25,7 @@ jobs:
name: Build container and manifests name: Build container and manifests
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
digest: ${{ steps.build.outputs.digest }} images: ${{ steps.images.outputs.images }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -63,7 +62,6 @@ jobs:
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ env.OCI_REPO }}
tags: | tags: |
type=edge type=edge
type=ref,event=branch type=ref,event=branch
@@ -71,23 +69,29 @@ jobs:
type=semver,pattern=v{{major}}.{{minor}} type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}} type=semver,pattern=v{{major}}
- name: Build container - name: Bake containers
id: build id: bake
uses: docker/build-push-action@v6 uses: docker/bake-action@v6
with: with:
context: . files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
push: true push: true
sbom: true sbom: true
provenance: mode=max provenance: mode=max
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
"RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
env: env:
TAG_BASE: ${{ env.OCI_REPO }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
- name: Output images
id: images
run: |
METADATA='${{ steps.bake.outputs.metadata }}'
IMAGES=$(echo ${METADATA} | jq 'map_values((."image.name" | split(",|:";""))[0] + "@" + ."containerimage.digest")')
echo images=${IMAGES} >> $GITHUB_OUTPUT
# TODO: Move this into docker-bake.hcl
- name: Generate CRDs - name: Generate CRDs
if: inputs.generate_crds == true if: inputs.generate_crds == true
run: | run: |
@@ -96,6 +100,7 @@ jobs:
- name: Kustomize manifests - name: Kustomize manifests
if: inputs.push_manifests == true if: inputs.push_manifests == true
run: | run: |
# TODO: Fix this
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml ./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml
- name: Push manifests - name: Push manifests