From 328bbbaaa21b93057b6e0e0c09a4f067f873d830 Mon Sep 17 00:00:00 2001 From: Unchained Date: Sun, 5 Apr 2026 08:13:46 +0200 Subject: [PATCH 1/2] ci: add Gitea Actions workflow with BuildKit --- .gitea/workflows/build.yaml | 116 ++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index f2fa685..efab700 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,60 +1,76 @@ -name: Build and Push to GHCR +name: Build and Deploy on: push: branches: [master, main] -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - jobs: build: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=sha,prefix=,suffix=,format=short - type=raw,value=latest,enable={{is_default_branch}} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Update kustomization.yaml + - name: Trigger BuildKit Build run: | - COMMIT_SHA=${{ github.sha }} - SHORT_SHA=${COMMIT_SHA:0:7} - sed -i "s|newTag: .*|newTag: ${SHORT_SHA}|" k8s/kustomization.yaml - - - name: Commit and push changes - run: | - git config --local user.email "gitea-actions[bot]@users.noreply.gitea.io" - git config --local user.name "gitea-actions[bot]" - git add k8s/kustomization.yaml - git diff --quiet && git diff --staged --quiet || git commit -m "deploy: update image to ${SHORT_SHA} [skip ci]" - git push + echo "Building commit: ${GITHUB_SHA}" + + # Delete old job + kubectl delete job build-manoon-headless-action -n gitea --ignore-not-found=true 2>/dev/null || true + + # Create build job + kubectl apply -f - << EOF + apiVersion: batch/v1 + kind: Job + metadata: + name: build-manoon-headless-action + namespace: gitea + spec: + ttlSecondsAfterFinished: 86400 + template: + spec: + restartPolicy: Never + initContainers: + - name: clone + image: alpine/git:latest + command: + - sh + - -c + - | + set -e + git clone --depth 1 http://gitea:3000/unchained/manoon-headless.git /workspace + cd /workspace && git checkout ${GITHUB_SHA} + echo "Building: \$(git rev-parse --short HEAD)" + volumeMounts: + - name: workspace + mountPath: /workspace + containers: + - name: build + image: moby/buildkit:latest + command: + - sh + - -c + - | + set -e + mkdir -p /root/.docker + cp /docker-config/.dockerconfigjson /root/.docker/config.json + buildctl --addr tcp://buildkit.gitea.svc.cluster.local:1234 build \ + --frontend dockerfile.v0 \ + --local context=/workspace \ + --local dockerfile=/workspace \ + --output type=image,name=ghcr.io/unchainedio/manoon-headless:latest,push=true + kubectl annotate kustomization -n flux-system manoonoils-storefront --overwrite reconcile.fluxcd.io/requestedAt="\$(date +%s)" + echo "Done!" + volumeMounts: + - name: workspace + mountPath: /workspace + - name: docker-config + mountPath: /docker-config + readOnly: true + volumes: + - name: workspace + emptyDir: {} + - name: docker-config + secret: + secretName: ghcr-pull-secret + EOF + + echo "Build job created!" + kubectl wait --for=condition=complete job/build-manoon-headless-action -n gitea --timeout=600s || echo "Build running in background" From 80da03504cb20ee7f85b0eddf68af6eb9f50953c Mon Sep 17 00:00:00 2001 From: Flux CD Date: Sun, 5 Apr 2026 06:16:10 +0000 Subject: [PATCH 2/2] ci: add Gitea Actions workflow with BuildKit --- .gitea/workflows/build.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index efab700..472e7a6 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,7 +10,7 @@ jobs: steps: - name: Trigger BuildKit Build run: | - echo "Building commit: ${GITHUB_SHA}" + echo "Building commit: \" # Delete old job kubectl delete job build-manoon-headless-action -n gitea --ignore-not-found=true 2>/dev/null || true @@ -36,8 +36,7 @@ jobs: - | set -e git clone --depth 1 http://gitea:3000/unchained/manoon-headless.git /workspace - cd /workspace && git checkout ${GITHUB_SHA} - echo "Building: \$(git rev-parse --short HEAD)" + cd /workspace && git checkout echo "Building: $(git rev-parse --short HEAD)" volumeMounts: - name: workspace mountPath: /workspace @@ -56,7 +55,7 @@ jobs: --local context=/workspace \ --local dockerfile=/workspace \ --output type=image,name=ghcr.io/unchainedio/manoon-headless:latest,push=true - kubectl annotate kustomization -n flux-system manoonoils-storefront --overwrite reconcile.fluxcd.io/requestedAt="\$(date +%s)" + kubectl annotate kustomization -n flux-system manoonoils-storefront --overwrite reconcile.fluxcd.io/requestedAt="\1775369769" echo "Done!" volumeMounts: - name: workspace