Compare commits

11 Commits
v1 ... v2

Author SHA1 Message Date
956337b9bd feat: Remove telegram notification
Gitea now supports email notifications when builds fail.
2025-12-21 22:21:14 +01:00
d062ec1f98 feat: Move workflow 2025-12-21 21:16:56 +01:00
478763d87d fix: Fix image digest replacement 2025-12-21 19:48:13 +01:00
5e558b2b23 fix: Tagging manifests does not work 2025-12-21 17:26:24 +01:00
a053eb45d2 fix: push_manifests option not working 2025-12-21 17:02:13 +01:00
9798363981 fix: Build fails if webhook fails 2025-12-21 16:19:24 +01:00
e0de3bb4b5 feat: Removed generate crds
This is now instead done using docker bake
2025-12-21 16:01:47 +01:00
74862f84ee feat: Handle non image targets 2025-12-21 15:59:51 +01:00
ef78704b98 Use Docker bake to build targets 2025-11-20 01:09:07 +01:00
d4842f1cda Renamed upload_manifests to push_manifests 2025-11-16 19:58:27 +01:00
2ab1019ce7 Renamed workflow to reflect what is does better 2025-11-16 19:57:44 +01:00

View File

@@ -3,30 +3,26 @@ name: Build and deploy
on:
workflow_call:
inputs:
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}}
OCI_REPO: git.huizinga.dev/${{ gitea.repository_owner}}/${{gitea.event.repository.name}}
jobs:
build:
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 +45,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 +59,6 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.OCI_REPO }}
tags: |
type=edge
type=ref,event=branch
@@ -71,35 +66,38 @@ 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: Generate CRDs
if: inputs.generate_crds == true
- name: Output images
id: images
run: |
docker run --rm ${{ env.OCI_REPO }}@${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
METADATA='${{ steps.bake.outputs.metadata }}'
IMAGES=$(echo ${METADATA} | jq 'map_values((."image.name" | select(. != null) | split(",|:";""))[0] + "@" + ."containerimage.digest")')
echo images=${IMAGES} >> $GITHUB_OUTPUT
- name: Kustomize manifests
if: inputs.upload_manifests == true
if: inputs.push_manifests == 'true'
run: |
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml
curl -L https://github.com/hairyhenderson/gomplate/releases/download/v4.3.3/gomplate_linux-amd64 -o gomplate
chmod +x ./gomplate
echo ${{ steps.images.outputs.images }} > ./images.json
./kustomize build ./manifests | ./gomplate --context images="file://${PWD}/images.json" > ./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" \
@@ -108,24 +106,9 @@ jobs:
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^/--tag /')
- name: Call webhook
if: inputs.webhook_url != ''
run: |
curl ${{ inputs.webhook_url }}
- name: Notify build status
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
# TODO: Escaping issues need to be solved first
# format: markdown
message: |
🚨 *BUILD FAILED!*
${{ gitea.repository }} (#${{ gitea.run_number }})
[${{ gitea.ref_name }}@sha1:${{ gitea.sha }}]
> ${{ gitea.event.head_commit.message }}
curl ${{ inputs.webhook_url }} || true