From ed589570661d6185747d83f18cc91f805ee743bd Mon Sep 17 00:00:00 2001 From: "t.behrendt" Date: Mon, 1 Sep 2025 12:27:05 +0200 Subject: [PATCH 1/3] ci: feat add ci pipeline to check build --- .gitea/workflows/ci.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..76ae730 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,24 @@ +name: CI + +on: + pull_request: + +jobs: + build: + name: Build Docker image + runs-on: + - ubuntu-latest + - linux_amd64 + steps: + - uses: actions/checkout@v5 + - uses: docker/setup-buildx-action@v3 + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: false + provenance: false + tags: | + backupsidecar:ci-test -- 2.49.1 From 75a73549fb332189f5d15cefcfe7512c8fb94501 Mon Sep 17 00:00:00 2001 From: "t.behrendt" Date: Mon, 1 Sep 2025 12:27:29 +0200 Subject: [PATCH 2/3] refactor: cd to include tags --- .gitea/workflows/cd.yaml | 148 +++++++++++++++++++++++---------------- 1 file changed, 87 insertions(+), 61 deletions(-) diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 485e3c1..4b4337a 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -1,83 +1,109 @@ -name: Build and Release Docker Image +name: CD on: push: branches: - main +env: + DOCKER_REGISTRY: gitea.t000-n.de + jobs: - build_amd64: - name: Build and Push amd64 - runs-on: [ubuntu-latest, linux_amd64] + check-changes: + name: Check changes + runs-on: ubuntu-latest + outputs: + changes: ${{ steps.filter.outputs.code }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v5 - - name: Log in to registry - uses: docker/login-action@v3 + - name: Get changed files + id: filter + uses: dorny/paths-filter@v3 with: - registry: gitea.t000-n.de - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} + filters: | + code: + - 'src/**' + - 'Dockerfile' + - 'gitea/workflows/**' - - name: Build Docker image for amd64 - run: | - docker build \ - --platform linux/amd64 \ - -f Dockerfile \ - -t gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-amd64 \ - . - - - name: Push Docker image for amd64 - run: | - docker push gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-amd64 - - build_arm64: - name: Build and Push arm64 - runs-on: [ubuntu-latest, linux_arm64] + build_and_push: + name: Build and push + needs: + - check-changes + if: ${{ needs.check-changes.outputs.changes != '0' }} + strategy: + matrix: + arch: + - amd64 + runs-on: + - ubuntu-latest + - linux_${{ matrix.arch }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log in to registry - uses: docker/login-action@v3 + - uses: actions/checkout@v5 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 with: - registry: gitea.t000-n.de - username: ${{ secrets.REGISTRY_USERNAME }} + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Build Docker image for arm64 + - id: meta run: | - docker build \ - --platform linux/arm64 \ - -f Dockerfile \ - -t gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-arm64 \ - . + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + - uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/${{ matrix.arch }} + push: true + provenance: false + tags: | + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-${{ matrix.arch }} - - name: Push Docker image for arm64 + create_tag: + name: Create tag + needs: + - check-changes + if: ${{ needs.check-changes.outputs.changes != '0' }} + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.new-tag }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@0.0.2 + id: tag + with: + token: ${{ secrets.GITEA_TOKEN }} + - run: | + git tag ${{ steps.tag.outputs.new-tag }} + git push origin ${{ steps.tag.outputs.new-tag }} + - name: Set output run: | - docker push gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-arm64 + echo "tag=${{ steps.tag.outputs.new-tag }}" >> $GITHUB_OUTPUT - manifest: - name: Create and Push Multi-Arch Manifest - needs: [build_amd64, build_arm64] + create_manifest: + name: Create manifest + needs: + - build_and_push + - create_tag runs-on: ubuntu-latest steps: - - name: Log in to registry - uses: docker/login-action@v3 - with: - registry: gitea.t000-n.de - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Create and push manifest with git SHA + - uses: actions/checkout@v5 + - id: meta run: | - docker manifest create gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }} \ - gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-amd64 \ - gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-arm64 - docker manifest push gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }} + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + - uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - run: | + docker manifest create ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} \ + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64 - docker manifest create gitea.t000-n.de/t.behrendt/backupsidecar:latest \ - gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-amd64 \ - gitea.t000-n.de/t.behrendt/backupsidecar:${{ github.sha }}-arm64 - docker manifest push gitea.t000-n.de/t.behrendt/backupsidecar:latest + docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} -- 2.49.1 From c6df446a38c8879c6b93410c03bee77c0203e0f7 Mon Sep 17 00:00:00 2001 From: "t.behrendt" Date: Mon, 1 Sep 2025 12:29:29 +0200 Subject: [PATCH 3/3] add arm64 support --- .gitea/workflows/cd.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 4b4337a..a3fa395 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -37,6 +37,7 @@ jobs: matrix: arch: - amd64 + - arm64 runs-on: - ubuntu-latest - linux_${{ matrix.arch }} @@ -104,6 +105,7 @@ jobs: password: ${{ secrets.REGISTRY_PASSWORD }} - run: | docker manifest create ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} \ - ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64 + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64 \ + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-arm64 docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} -- 2.49.1