Skip to content

Commit

Permalink
remove digest based merge strategy (#685)
Browse files Browse the repository at this point in the history
* remove digest based merge strategy

* use env.REGISTRY_NAME
  • Loading branch information
d4mr authored Sep 26, 2024
1 parent f38aa73 commit cbf33f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 81 deletions.
48 changes: 8 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -36,59 +31,32 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push by digest
- name: Build and push image
id: build
uses: docker/build-push-action@v6
with:
context: .
target: prod
push: true
tags: thirdweb/engine:nightly-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
build-args: ENGINE_VERSION=nightly

- 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@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
merge-manifests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:nightly \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
- name: Create and Push Multi-arch Manifest
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:nightly
docker manifest create ${{ env.REGISTRY_IMAGE }}:nightly \
${{ env.REGISTRY_IMAGE }}:nightly-amd64 \
${{ env.REGISTRY_IMAGE }}:nightly-arm64
docker manifest push ${{ env.REGISTRY_IMAGE }}:nightly
53 changes: 12 additions & 41 deletions .github/workflows/tagBasedImageBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
with:
ref: ${{ github.event.release.target_commitish }}

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -46,62 +41,38 @@ jobs:
context: .
target: prod
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
${{ env.LATEST_TAG != '' && format('thirdweb/engine:latest-{0}', matrix.platform == 'linux/amd64' && 'amd64' || 'arm64') || '' }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
build-args: ENGINE_VERSION=${{ github.event.release.tag_name }}

- 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@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge-manifests:
needs: build
runs-on: ubuntu-latest
env:
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and Push Multi-arch Manifest (release tag)
working-directory: /tmp/digests
- name: Create and Push Multi-arch Manifest (release tag)
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
docker manifest create ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} \
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-amd64 \
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-arm64
docker manifest push ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}
- name: Create and Push Multi-arch Manifest (latest tag) (if applicable)
if: ${{ env.LATEST_TAG != '' }}
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest \
${{ env.REGISTRY_IMAGE }}@sha256:${{ steps.build.outputs.digest }}
- name: Inspect image
- name: Create and Push Multi-arch Manifest (latest tag) (if applicable)
if: ${{ env.LATEST_TAG != '' }}
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}
docker manifest create ${{ env.REGISTRY_IMAGE }}:latest \
${{ env.REGISTRY_IMAGE }}:latest-arm64 \
${{ env.REGISTRY_IMAGE }}:latest-amd64
docker manifest push ${{ env.REGISTRY_IMAGE }}:latest

0 comments on commit cbf33f9

Please sign in to comment.