Skip to content

Commit 2eab619

Browse files
committed
123
1 parent e7e7836 commit 2eab619

File tree

1 file changed

+102
-2
lines changed

1 file changed

+102
-2
lines changed

.github/workflows/build-and-release-services-images.yml

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout repository
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Set up Docker Buildx
2525
uses: docker/setup-buildx-action@v2
@@ -81,7 +81,107 @@ jobs:
8181
done <<< "${{ steps.meta.outputs.tags }}"
8282
8383
# Build and push the Docker image with all tags
84-
docker buildx build --platform linux/amd64,linux/arm64 \
84+
docker buildx build --platform linux/amd64\
85+
--file "$dockerfile" \
86+
"${tag_args[@]}" \
87+
--push \
88+
"."
89+
90+
else
91+
echo "No valid Dockerfile found in $dir"
92+
fi
93+
done
94+
- name: Verify multi-platform support
95+
run: |
96+
for dir in build/images/*/; do
97+
IMAGE_NAME=$(basename "$dir" | tr '[:upper:]' '[:lower:]')
98+
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
99+
manifest=$(docker manifest inspect "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag" || echo "error")
100+
if [[ "$manifest" == "error" ]]; then
101+
echo "Manifest not found for $IMAGE_NAME:$tag"
102+
exit 1
103+
fi
104+
amd64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "amd64")')
105+
arm64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "arm64")')
106+
if [[ -z "$amd64_found" ]]; then
107+
echo "Multi-platform support check failed for $IMAGE_NAME:$tag - missing amd64"
108+
exit 1
109+
fi
110+
if [[ -z "$arm64_found" ]]; then
111+
echo "Multi-platform support check failed for $IMAGE_NAME:$tag - missing arm64"
112+
exit 1
113+
fi
114+
done
115+
done
116+
117+
build-and-arm:
118+
runs-on: ubuntu-latest
119+
120+
steps:
121+
- name: Checkout repository
122+
uses: actions/checkout@v4
123+
124+
- name: Set up Docker Buildx
125+
uses: docker/setup-buildx-action@v2
126+
127+
- name: Log in to Docker Hub
128+
uses: docker/login-action@v2
129+
with:
130+
username: ${{ secrets.DOCKER_USERNAME }}
131+
password: ${{ secrets.DOCKER_PASSWORD }}
132+
133+
- name: Log in to GitHub Container Registry
134+
uses: docker/login-action@v2
135+
with:
136+
registry: ghcr.io
137+
username: ${{ github.repository_owner }}
138+
password: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: Log in to Aliyun Container Registry
141+
uses: docker/login-action@v2
142+
with:
143+
registry: registry.cn-hangzhou.aliyuncs.com
144+
username: ${{ secrets.ALIREGISTRY_USERNAME }}
145+
password: ${{ secrets.ALIREGISTRY_TOKEN }}
146+
147+
- name: Extract metadata for Docker (tags, labels)
148+
id: meta
149+
uses: docker/metadata-action@v5
150+
with:
151+
tags: |
152+
type=ref,event=tag
153+
type=schedule
154+
type=ref,event=branch
155+
type=semver,pattern={{version}}
156+
type=semver,pattern=v{{version}}
157+
# type=semver,pattern={{major}}.{{minor}}
158+
type=semver,pattern=release-{{raw}}
159+
type=sha
160+
type=raw,value=${{ github.event.inputs.tag }}
161+
162+
- name: Build and push Docker images
163+
run: |
164+
IMG_DIR="build/images"
165+
for dir in "$IMG_DIR"/*/; do
166+
# Find Dockerfile or *.dockerfile in a case-insensitive manner
167+
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
168+
169+
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
170+
IMAGE_NAME=$(basename "$dir")
171+
echo "Building Docker image for $IMAGE_NAME with tags:"
172+
173+
# Initialize tag arguments
174+
tag_args=()
175+
176+
# Read each tag and append --tag arguments
177+
while IFS= read -r tag; do
178+
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
179+
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
180+
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
181+
done <<< "${{ steps.meta.outputs.tags }}"
182+
183+
# Build and push the Docker image with all tags
184+
docker buildx build --platform linux/arm64 \
85185
--file "$dockerfile" \
86186
"${tag_args[@]}" \
87187
--push \

0 commit comments

Comments
 (0)