From 41100f53ad0a52fe67de232a8a5ed4da4fcbb885 Mon Sep 17 00:00:00 2001 From: Nicolas Gruel Date: Fri, 26 Apr 2024 14:27:17 +0200 Subject: [PATCH] ci: use github action for docker push --- .github/workflows/build.yml | 96 ++++++++----------- .../ArmoniK.EndToEndTests.Worker/Dockerfile | 2 +- 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e5f239e5..60ccc3e99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,8 @@ on: - main - "[0-9]+.[0-9]+.x" +env: + REGISTRY_IMAGE: dockerhubaneo/armonik_worker_dll jobs: versionning: @@ -17,27 +19,23 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.genver.outputs.version }} - release: ${{ steps.genver.outputs.release }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: ref: ${{ github.ref }} fetch-depth: 0 - name: Generate Version id: genver - run: | - VERSION=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }}-pre --dev-branch=main) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "VERSION : $VERSION" - RELEASE=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }} --dev-branch=main) - echo "release=$RELEASE" >> $GITHUB_OUTPUT - echo "RELEASE : $RELEASE" - echo "Version :" >> $GITHUB_STEP_SUMMARY - echo "$VERSION" >> $GITHUB_STEP_SUMMARY - echo "Release :" >> $GITHUB_STEP_SUMMARY - echo "$RELEASE" >> $GITHUB_STEP_SUMMARY + uses: codacy/git-version@80c816f11db8dea5e3a81025f598193015b51832 # 2.8.0 + with: + minor-identifier: "feat:" + release-branch: release + dev-branch: main + + - name: Print version + run: echo VERSION ${{ steps.genver.outputs.version }} >> $GITHUB_STEP_SUMMARY buildProjects: runs-on: ubuntu-latest @@ -64,81 +62,68 @@ jobs: run: | find /tmp/packages -name 'ArmoniK*.nupkg' ! -name '*test*.nupkg' -exec dotnet nuget push {} -k ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \; - buildWorkerEnd2End: + buildDocker: runs-on: ubuntu-latest needs: - versionning + - buildProjects env: VERSION: ${{ needs.versionning.outputs.version }} + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 steps: + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.ref }} submodules: true - - name: login - run: | - echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} --password-stdin - - - name: build - run: | - docker build -t dockerhubaneo/armonik_worker_dll:$VERSION -f Worker/src/DLLWorker/Dockerfile . - - - name: push - run: | - docker push dockerhubaneo/armonik_worker_dll:$VERSION - - - buildImagesCross: - runs-on: ubuntu-latest - needs: - - versionning - - buildWorkerEnd2End - env: - VERSION: ${{ needs.versionning.outputs.version }} - steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 with: - ref: ${{ github.ref }} + images: ${{ env.REGISTRY_IMAGE }} - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: login - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_LOGIN }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: platforms - run: echo ${{ steps.buildx.outputs.platforms }} - - name: Build and push - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4 + uses: docker/build-push-action@v5 with: file: Worker/src/DLLWorker/Dockerfile context: . - platforms: linux/arm64 + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} push: true - provenance: mode=max + #provenance: mode=max + provenance: true sbom: true - tags: | - dockerhubaneo/armonik_worker_dll:${{ needs.versionning.outputs.version }}-arm - - - name: Create multi-arch manifest - run: docker buildx imagetools create dockerhubaneo/armonik_worker_dll:${VERSION} --tag dockerhubaneo/armonik_worker_dll:${VERSION} --provenance=true --sbom=true --append dockerhubaneo/armonik_worker_dll:${VERSION}-arm + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true testEndToEnd: needs: - versionning - buildProjects - - buildWorkerEnd2End + - buildDocker strategy: fail-fast: false matrix: @@ -267,7 +252,7 @@ jobs: runs-on: ubuntu-latest needs: - versionning - - buildWorkerEnd2End + - buildDocker env: VERSION: ${{ needs.versionning.outputs.version }} steps: @@ -322,3 +307,4 @@ jobs: steps: - name: Echo OK run: echo OK + diff --git a/Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Worker/Dockerfile b/Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Worker/Dockerfile index 38d41eb5f..c6bfb9302 100644 --- a/Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Worker/Dockerfile +++ b/Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Worker/Dockerfile @@ -1,4 +1,4 @@ -ARG WORKER_DLL_IMAGE=dockerhubaneo/armonik_worker_dll:0.14.5 +ARG WORKER_DLL_IMAGE=dockerhubaneo/armonik_worker_dll:0.14.6 FROM mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim AS build WORKDIR /src