From d434361883058416c7ae222b98b271f145f6913c Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Sep 2023 10:04:29 +0300 Subject: [PATCH 1/9] add manual trigger to docker_crossbuild_publish.yml --- .github/workflows/docker_crossbuild_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index a08a91b3..0a7af497 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -6,6 +6,7 @@ on: - opened - synchronize - closed + workflow_dispatch: jobs: build: @@ -64,4 +65,3 @@ jobs: platforms: linux/amd64,linux/arm64 tags: greenden/oracle-core:${{ github.ref_name }}, greenden/oracle-core:latest push: true - From c3ca96e53fa4f4f975314721182b6d5cab67fd28 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Sep 2023 10:32:32 +0300 Subject: [PATCH 2/9] use github.sha instead of github.ref_name in docker push --- .github/workflows/docker_crossbuild_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 0a7af497..c24460c0 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -63,5 +63,5 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - tags: greenden/oracle-core:${{ github.ref_name }}, greenden/oracle-core:latest + tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest push: true From b2f6792912ac5442566c8d49eaccbbf2974f62c6 Mon Sep 17 00:00:00 2001 From: Boris P Date: Tue, 5 Sep 2023 08:12:44 -0600 Subject: [PATCH 3/9] testing: change to type=sha --- .github/workflows/docker_crossbuild_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index c24460c0..599759f0 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -32,7 +32,7 @@ jobs: with: images: greenden/oracle-core tags: | - type=ref,event=tag + type=sha - name: Build images uses: docker/build-push-action@v3 with: From 676a9d855aec64454e3d2ad299bf6bae3e93d9e8 Mon Sep 17 00:00:00 2001 From: Boris P Date: Tue, 5 Sep 2023 09:53:31 -0600 Subject: [PATCH 4/9] test docker caching --- .github/workflows/docker_crossbuild_publish.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 599759f0..3120066f 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -25,7 +25,15 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Generate Docker metadata id: metadata uses: docker/metadata-action@v3 @@ -42,6 +50,8 @@ jobs: build-args: | TARGETPLATFORM=${{ matrix.platform }} CCARCH=${{ matrix.ccarch }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max push: false load: true @@ -64,4 +74,5 @@ jobs: context: . platforms: linux/amd64,linux/arm64 tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest + cache-from: type=local,src=/tmp/.buildx-cache push: true From ce15cad72d42d109c335304152f8f11115c1bda9 Mon Sep 17 00:00:00 2001 From: Boris P Date: Wed, 6 Sep 2023 21:43:28 -0600 Subject: [PATCH 5/9] test manifest list --- .../workflows/docker_crossbuild_publish.yml | 95 +++++++++++++------ 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 3120066f..9318b0aa 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -8,6 +8,9 @@ on: - closed workflow_dispatch: +env: + REGISTRY_IMAGE: greenden/oracle-core + jobs: build: runs-on: ubuntu-latest @@ -24,55 +27,85 @@ jobs: uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Generate Docker metadata id: metadata - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY_IMAGE }} + + - name: Login to DockerHub + uses: docker/login-action@v2 with: - images: greenden/oracle-core - tags: | - type=sha - - name: Build images + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push by digest uses: docker/build-push-action@v3 with: context: . platforms: ${{ matrix.platform }} - tags: ${{ steps.metadata.outputs.tags }} + #tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true build-args: | TARGETPLATFORM=${{ matrix.platform }} CCARCH=${{ matrix.ccarch }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=max - push: false - load: true - - push: + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v3 + with: + name: digests + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: needs: build runs-on: ubuntu-latest steps: + - name: Download digests + uses: actions/download-artifact@v3 + with: + name: digests + path: /tmp/digests + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - + uses: docker/setup-buildx-action@v2 + + - name: Generate Docker metadata + id: metadata + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY_IMAGE }} + - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Combine and Push to DockerHub - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64,linux/arm64 - tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest - cache-from: type=local,src=/tmp/.buildx-cache - push: true + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.metadata.outputs.version }} + + #- name: Combine and Push to DockerHub + # uses: docker/build-push-action@v3 + # with: + # context: . + # platforms: linux/amd64,linux/arm64 + # tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest + # cache-from: type=local,src=/tmp/.buildx-cache + # push: true From cdd7ff3b967da7cedba778dcec6908162c4567c1 Mon Sep 17 00:00:00 2001 From: Boris P Date: Wed, 6 Sep 2023 21:56:37 -0600 Subject: [PATCH 6/9] add missing id to build --- .github/workflows/docker_crossbuild_publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 9318b0aa..f17b2369 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -42,7 +42,8 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push by digest - uses: docker/build-push-action@v3 + id: build + uses: docker/build-push-action@v4 with: context: . platforms: ${{ matrix.platform }} From eeabf836f32362ef58f0880af1adb5120f3b0699 Mon Sep 17 00:00:00 2001 From: Boris P Date: Wed, 6 Sep 2023 23:38:21 -0600 Subject: [PATCH 7/9] test latest tag --- .github/workflows/docker_crossbuild_publish.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index f17b2369..2b522775 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -47,7 +47,6 @@ jobs: with: context: . platforms: ${{ matrix.platform }} - #tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true build-args: | @@ -86,6 +85,8 @@ jobs: uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY_IMAGE }} + flavor: | + latest=true - name: Login to DockerHub uses: docker/login-action@v2 @@ -101,12 +102,3 @@ jobs: - name: Inspect image run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.metadata.outputs.version }} - - #- name: Combine and Push to DockerHub - # uses: docker/build-push-action@v3 - # with: - # context: . - # platforms: linux/amd64,linux/arm64 - # tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest - # cache-from: type=local,src=/tmp/.buildx-cache - # push: true From bc1be1bd21bc7985d954b64ac7e8de57f0a10024 Mon Sep 17 00:00:00 2001 From: Boris P Date: Thu, 7 Sep 2023 00:00:20 -0600 Subject: [PATCH 8/9] trigger on published and set ergoplatform user --- .github/workflows/docker_crossbuild_publish.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 2b522775..026ad7e6 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -1,15 +1,12 @@ name: Cross-Compile Docker Build and Push on: - pull_request: - types: - - opened - - synchronize - - closed + release: + types: [published] workflow_dispatch: env: - REGISTRY_IMAGE: greenden/oracle-core + REGISTRY_IMAGE: ergoplatform/oracle-core jobs: build: From bfe1a95a642fde51f224de3d67de150b370ccf84 Mon Sep 17 00:00:00 2001 From: Boris P Date: Thu, 7 Sep 2023 00:07:11 -0600 Subject: [PATCH 9/9] remove extra spaces --- .github/workflows/docker_crossbuild_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_crossbuild_publish.yml b/.github/workflows/docker_crossbuild_publish.yml index 026ad7e6..c62e267c 100644 --- a/.github/workflows/docker_crossbuild_publish.yml +++ b/.github/workflows/docker_crossbuild_publish.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - + - name: Generate Docker metadata id: metadata uses: docker/metadata-action@v4