Skip to content

Commit

Permalink
[CI] Push multiarch image to both main and mirror repos (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonsyh authored Aug 9, 2024
1 parent 5ec0c10 commit 3c7426f
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/push_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ on:
- 'pyproject.toml'

env:
REGISTRY_IMAGE: mlenergy/zeus
REGISTRY_NAME: mlenergy/zeus
MIRROR_REGISTRY_NAME: symbioticlab/zeus
jobs:
build_and_push:
if: github.repository_owner == 'ml-energy'
Expand Down Expand Up @@ -58,8 +59,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
symbioticlab/zeus
mlenergy/zeus
${{ env.REGISTRY_NAME }}
${{ env.MIRROR_REGISTRY_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
Expand All @@ -73,7 +74,7 @@ jobs:
cache-from: type=registry,ref=mlenergy/zeus:buildcache
cache-to: type=registry,ref=mlenergy/zeus:buildcache,mode=max
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
outputs: type=image,name=${{ env.REGISTRY_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
Expand All @@ -86,8 +87,6 @@ jobs:
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
- name: List files in /tmp/digests
run: ls -l /tmp/digests

merge:
runs-on: ubuntu-latest
Expand All @@ -106,15 +105,15 @@ jobs:
with:
name: digests-linux-arm64
path: /tmp/digests/linux-arm64
- name: List files in /tmp/digests
run: ls -l /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
images: |
${{ env.REGISTRY_NAME }}
${{ env.MIRROR_REGISTRY_NAME }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -127,9 +126,9 @@ jobs:
digests=$(find /tmp/digests -type f -name '*.digest' | xargs cat)
cmd="docker buildx imagetools create $tags"
for digest in $digests; do
cmd="$cmd $REGISTRY_IMAGE@sha256:${digest#sha256:}"
cmd="$cmd $REGISTRY_NAME@sha256:${digest#sha256:}"
done
eval $cmd
eval $cmd
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.REGISTRY_NAME }}:${{ steps.meta.outputs.version }}

0 comments on commit 3c7426f

Please sign in to comment.