Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Dec 3, 2024
1 parent 602d757 commit f807d20
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,33 @@ jobs:
type=sha
type=raw,value=${{ github.event.inputs.tag }}
- name: Display tags for debugging
run: echo "${{ steps.meta.outputs.tags }}"

- name: Build and push Docker images
run: |
ROOT_DIR="build/images"
IMAGE_NAME=${{ matrix.image }}
dir="$ROOT_DIR/$IMAGE_NAME"
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
echo "Building Docker image for $IMAGE_NAME with tags:"
for dir in "$ROOT_DIR"/*/; do
# Find Dockerfile or *.dockerfile in a case-insensitive manner
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
tag_args=()
while IFS= read -r tag; do
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
done <<< "${{ steps.meta.outputs.tags }}"
docker buildx build --platform linux/amd64,linux/arm64 \
--file "$dockerfile" \
"${tag_args[@]}" \
--push "$dir"
if [ $? -ne 0 ]; then
echo "Docker buildx build failed for $IMAGE_NAME"
exit 1
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
IMAGE_NAME=$(basename "$dir")
echo "Building Docker image for $IMAGE_NAME with tags:"
# Initialize tag arguments
tag_args=()
# Read each tag and append --tag arguments
while IFS= read -r tag; do
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
done <<< "${{ steps.meta.outputs.tags }}"

# Build and push the Docker image with all tags
docker buildx build --platform linux/amd64,linux/arm64 \
--file "$dockerfile" \
"${tag_args[@]}" \
--push "$dir"
else
echo "No valid Dockerfile found in $dir"
fi
else
echo "No valid Dockerfile found in $dir"
fi
done

0 comments on commit f807d20

Please sign in to comment.