From 8abf3edfcd3b165d6d77d2cb7392cb8f8e52013a Mon Sep 17 00:00:00 2001 From: DaanSelen Date: Fri, 31 Oct 2025 12:31:25 +0100 Subject: [PATCH] feat: rewrite workflow --- .github/workflows/docker-build.yml | 99 ++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..e99b25a --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,99 @@ +# See https://docs.github.com/en/actions/publishing-packages/publishing-docker-images + +name: Build and push # to docker registries + +on: + workflow_dispatch: + release: + types: [published] + +env: + IMAGE_NAME: paessler/multi-platform-probe + +jobs: + docker_build: + name: Build and push + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + strategy: + fail-fast: false + matrix: + variant: + - name: dockerhub + registry: "docker.io" + - name: ghcr + registry: "ghcr.io" + steps: + - name: Check out the repository + uses: actions/checkout@v5 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: | + - linux/amd64 + - linux/arm64 + - linux/arm/v7 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + registry: ${{ matrix.variant.registry }} + + - name: Log in to Github Container Registry + uses: docker/login-action@v3 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ${{ matrix.variant.registry }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.IMAGE_NAME }} + ${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha,format=short,prefix= + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: | + - linux/amd64 + - linux/arm64 + - linux/arm/v7 + + - name: Generate artifact attestation + if: matrix.variant.name == 'dockerhub' + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ matrix.variant.registry }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + - name: Generate artifact attestation + if: matrix.variant.name == 'ghcr' + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ matrix.variant.registry }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true \ No newline at end of file