Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
ef78704b98
|
|||
|
d4842f1cda
|
|||
|
2ab1019ce7
|
@@ -6,17 +6,16 @@ on:
|
||||
generate_crds:
|
||||
description: Runs a binary called gencrd in the docker container and writes the output to ./manifests/crds.yaml
|
||||
type: boolean
|
||||
upload_manifests:
|
||||
description: Upload manifest files to OCI repository
|
||||
push_manifests:
|
||||
description: Push manifest files to OCI repository
|
||||
default: true
|
||||
type: boolean
|
||||
webhook_url:
|
||||
description: Webhook to call after build is completed
|
||||
type: string
|
||||
outputs:
|
||||
digest:
|
||||
description: Digest of the build docker container
|
||||
value: ${{ jobs.build.outputs.digest }}
|
||||
images:
|
||||
value: ${{ jobs.build.outputs.images }}
|
||||
|
||||
env:
|
||||
OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}}
|
||||
@@ -26,7 +25,7 @@ jobs:
|
||||
name: Build container and manifests
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
digest: ${{ steps.build.outputs.digest }}
|
||||
images: ${{ steps.images.outputs.images }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -49,12 +48,12 @@ jobs:
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Install kustomize
|
||||
if: inputs.upload_manifests == true
|
||||
if: inputs.push_manifests == true
|
||||
run: |
|
||||
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
|
||||
|
||||
- name: Setup Flux CLI
|
||||
if: inputs.upload_manifests == true
|
||||
if: inputs.push_manifests == true
|
||||
uses: https://github.com/fluxcd/flux2/action@main
|
||||
with:
|
||||
version: v2.5.0
|
||||
@@ -63,7 +62,6 @@ jobs:
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.OCI_REPO }}
|
||||
tags: |
|
||||
type=edge
|
||||
type=ref,event=branch
|
||||
@@ -71,35 +69,42 @@ jobs:
|
||||
type=semver,pattern=v{{major}}.{{minor}}
|
||||
type=semver,pattern=v{{major}}
|
||||
|
||||
- name: Build container
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
- name: Bake containers
|
||||
id: bake
|
||||
uses: docker/bake-action@v6
|
||||
with:
|
||||
context: .
|
||||
files: |
|
||||
./docker-bake.hcl
|
||||
cwd://${{ steps.meta.outputs.bake-file }}
|
||||
push: true
|
||||
sbom: true
|
||||
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:
|
||||
TAG_BASE: ${{ env.OCI_REPO }}
|
||||
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
|
||||
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
|
||||
if: inputs.generate_crds == true
|
||||
run: |
|
||||
docker run --rm ${{ env.OCI_REPO }}@${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
|
||||
|
||||
- name: Kustomize manifests
|
||||
if: inputs.upload_manifests == true
|
||||
if: inputs.push_manifests == true
|
||||
run: |
|
||||
# TODO: Fix this
|
||||
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml
|
||||
|
||||
- name: Push manifests
|
||||
if: inputs.upload_manifests == true
|
||||
if: inputs.push_manifests == true
|
||||
run: |
|
||||
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
||||
--path="./manifests.yaml" \
|
||||
Reference in New Issue
Block a user