Skip to content

Commit 8e2bf96

Browse files
authored
Update docker-publish.yml
1 parent cde3bdf commit 8e2bf96

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/docker-publish.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,25 @@ jobs:
3131
id: extract_tag
3232
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
3333

34+
- name: Extract Base Image from Dockerfile
35+
id: get_base_image
36+
run: |
37+
BASE_IMAGE=$(grep -i '^FROM' Dockerfile | head -n 1 | awk '{print $2}')
38+
echo "BASE_IMAGE=$BASE_IMAGE" >> $GITHUB_ENV
39+
40+
- name: Get Supported Platforms
41+
id: get_platforms
42+
run: |
43+
PLATFORMS=$(docker buildx imagetools inspect ${{ env.BASE_IMAGE }} --format '{{ range .Manifest.Platforms }}{{ .OS }}/{{ .Architecture }},{{ end }}' | sed 's/,$//')
44+
echo "PLATFORMS=$PLATFORMS" >> $GITHUB_ENV
45+
shell: bash
46+
3447
- name: Build and Push Docker Image (Multi-Arch)
3548
uses: docker/build-push-action@v5
3649
with:
3750
context: .
3851
push: true
39-
platforms: linux/amd64, linux/arm64, linux/arm/v7, windows/amd64, darwin/amd64
52+
platforms: ${{ env.PLATFORMS }}
4053
tags: |
4154
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
4255
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

0 commit comments

Comments
 (0)