Skip to content

Commit d97a2e7

Browse files
committed
Correctly set tags in manifest using unique SHA
1 parent accf4a9 commit d97a2e7

File tree

1 file changed

+47
-23
lines changed

1 file changed

+47
-23
lines changed

.github/workflows/docker-build.yml

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,35 +97,59 @@ jobs:
9797

9898
- name: Create and push CPU manifest
9999
run: |
100-
# Create and push multi-architecture manifest for CPU variant
101-
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cpu \
102-
ghcr.io/${{ github.repository }}:cpu-amd64 \
103-
ghcr.io/${{ github.repository }}:cpu-arm64
100+
# Determine the correct tag suffixes based on the event type
101+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
102+
# PR build - use the commit SHA for more predictable references
103+
AMD64_TAG="cpu-amd64-sha-${{ github.sha }}"
104+
ARM64_TAG="cpu-arm64-sha-${{ github.sha }}"
105+
TARGET_TAG="cpu-sha-${{ github.sha }}"
106+
elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
107+
# Tag build - use tag version in the name
108+
AMD64_TAG="cpu-amd64-${{ github.ref_name }}"
109+
ARM64_TAG="cpu-arm64-${{ github.ref_name }}"
110+
TARGET_TAG="cpu-${{ github.ref_name }}"
111+
else
112+
# Main branch build - use simple arch tags
113+
AMD64_TAG="cpu-amd64"
114+
ARM64_TAG="cpu-arm64"
115+
TARGET_TAG="cpu"
116+
fi
117+
118+
# Create the manifest with the correct tag names
119+
echo "Creating CPU manifest using $AMD64_TAG and $ARM64_TAG"
120+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${TARGET_TAG} \
121+
ghcr.io/${{ github.repository }}:${AMD64_TAG} \
122+
ghcr.io/${{ github.repository }}:${ARM64_TAG}
104123
105124
# If on main branch, also tag as latest
106125
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
107126
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:latest \
108-
ghcr.io/${{ github.repository }}:cpu-amd64 \
109-
ghcr.io/${{ github.repository }}:cpu-arm64
110-
fi
111-
112-
# If this is a tag, add version tag for CPU
113-
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
114-
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cpu-${{ github.ref_name }} \
115-
ghcr.io/${{ github.repository }}:cpu-amd64 \
116-
ghcr.io/${{ github.repository }}:cpu-arm64
127+
ghcr.io/${{ github.repository }}:${AMD64_TAG} \
128+
ghcr.io/${{ github.repository }}:${ARM64_TAG}
117129
fi
118130
119131
- name: Create and push CUDA manifest
120132
run: |
121-
# Create and push multi-architecture manifest for CUDA variant
122-
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cuda \
123-
ghcr.io/${{ github.repository }}:cuda-amd64 \
124-
ghcr.io/${{ github.repository }}:cuda-arm64
125-
126-
# If this is a tag, add version tag for CUDA
127-
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
128-
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cuda-${{ github.ref_name }} \
129-
ghcr.io/${{ github.repository }}:cuda-amd64 \
130-
ghcr.io/${{ github.repository }}:cuda-arm64
133+
# Determine the correct tag suffixes based on the event type
134+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
135+
# PR build - use the commit SHA for more predictable references
136+
AMD64_TAG="cuda-amd64-sha-${{ github.sha }}"
137+
ARM64_TAG="cuda-arm64-sha-${{ github.sha }}"
138+
TARGET_TAG="cuda-sha-${{ github.sha }}"
139+
elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
140+
# Tag build - use tag version in the name
141+
AMD64_TAG="cuda-amd64-${{ github.ref_name }}"
142+
ARM64_TAG="cuda-arm64-${{ github.ref_name }}"
143+
TARGET_TAG="cuda-${{ github.ref_name }}"
144+
else
145+
# Main branch build - use simple arch tags
146+
AMD64_TAG="cuda-amd64"
147+
ARM64_TAG="cuda-arm64"
148+
TARGET_TAG="cuda"
131149
fi
150+
151+
# Create the manifest with the correct tag names
152+
echo "Creating CUDA manifest using $AMD64_TAG and $ARM64_TAG"
153+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${TARGET_TAG} \
154+
ghcr.io/${{ github.repository }}:${AMD64_TAG} \
155+
ghcr.io/${{ github.repository }}:${ARM64_TAG}

0 commit comments

Comments
 (0)