From b8a2752203464ab5f3d12ecda86250db67361984 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 18 Mar 2025 02:24:26 +0100 Subject: [PATCH] Added gitea action to build container and manifests --- .gitea/workflows/build.yaml | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .gitea/workflows/build.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..2534ad5 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,83 @@ +name: Build and deploy +on: + push: + branches: + - master + - feature/** + tags: + - v*.*.* + +jobs: + build: + name: Build container + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: git.huizinga.dev + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Build and push Docker image + uses: https://github.com/docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + manifests: + name: Publish manifests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install kustomize + run: | + curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash + + - name: Setup Flux CLI + uses: https://github.com/fluxcd/flux2/action@main + with: + version: v2.5.0 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: git.huizinga.dev + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # TODO: Generate and include crds + - name: Generate manifets + run: | + ./kustomize build ./manifests | sed "s/\${SHA_SHORT}/$(git rev-parse --short HEAD)/" > ./app.yaml + + - name: Push manifests + run: | + flux push artifact oci://git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name }}/manifests:sha-$(git rev-parse --short HEAD) \ + --path="./app.yaml" \ + --source="$(git config --get remote.origin.url)" \ + --revision="$(git branch --show-current)@sha1:$(git rev-parse HEAD)" + + - name: Tag manifests + run: | + flux tag artifact oci://git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name }}/manifests:sha-$(git rev-parse --short HEAD) \ + --tag latest