diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ae15e85..ab7a8db 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -18,6 +18,12 @@ jobs: runs-on: ubuntu-latest steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: actions/checkout@v4 with: lfs: true @@ -31,6 +37,15 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Docker Build & Publish - run: bash ci/docker-publish.sh + id: taggen + run: bash ci/docker-gen-tagnames.sh + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.taggen.outputs.docker_build_tags }} ... diff --git a/ci/docker-publish.sh b/ci/docker-gen-tagnames.sh similarity index 59% rename from ci/docker-publish.sh rename to ci/docker-gen-tagnames.sh index b7ea30c..7882820 100644 --- a/ci/docker-publish.sh +++ b/ci/docker-gen-tagnames.sh @@ -5,7 +5,7 @@ function log() { echo "[$(date +%H:%M:%S)] $@" >&2 } -[[ -n $GITHUB_REF_NAME ]] || { +[[ -n ${GITHUB_REF_NAME:-} ]] || { log "ERR: This script is intended to run on a Github Action only." exit 1 } @@ -16,11 +16,11 @@ tags=() case "${GITHUB_REF_TYPE}" in branch) # Generic build to develop: Workflow has to limit branches to master - tags+=(develop) + tags+=("${repo}:develop") ;; tag) # Build to latest & tag: Older tags are not intended to rebuild - tags+=(latest ${GITHUB_REF_NAME}) + tags+=("${repo}:latest" "${repo}:${GITHUB_REF_NAME}") ;; *) log "ERR: The ref type ${GITHUB_REF_TYPE} is not handled." @@ -28,13 +28,5 @@ tag) ;; esac -log "Building Docker image..." -docker build -t "${repo}:local" . - -for ref in "${tags[@]}"; do - log "Pushing Docker image to '${repo}:${ref}'..." - docker tag "${repo}:local" "${repo}:${ref}" - docker push "${repo}:${ref}" -done - -log "Publish finished." +export IFS=, +echo "docker_build_tags=${tags[*]}" >>${GITHUB_OUTPUT}