From c2d2111daacfa98271e54c93a1c8b2e05ec80e00 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Tue, 3 Dec 2024 14:11:42 +0800 Subject: [PATCH] upd --- .github/workflows/docker-build.yml | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 7a6fd68..35cccdf 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -83,17 +83,22 @@ jobs: - name: Build and push Docker images run: | ROOT_DIR="build/images" - for dir in "$ROOT_DIR"/*/; do - Dockerfile=$(ls "$dir" | grep -iE '(^dockerfile$|\.dockerfile$)' | head -n 1) - if [ -f "$dir/$Dockerfile" ]; then - IMAGE_NAME=$(basename "$dir") - echo "Building Docker image for $IMAGE_NAME with tags ${{ steps.meta.outputs.tags }}..." - docker buildx build --platform linux/amd64,linux/arm64 \ - --tag ${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:${{ steps.meta.outputs.tags }} \ - --tag ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:${{ steps.meta.outputs.tags }} \ - --tag registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:${{ steps.meta.outputs.tags }} \ - --push "$dir" - else - echo "No .dockerfile found in $dir" - fi - done \ No newline at end of file + while IFS= read -r tag; do + 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) + + if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then + IMAGE_NAME=$(basename "$dir") + echo "Building Docker image for $IMAGE_NAME with tag $tag..." + docker buildx build --platform linux/amd64,linux/arm64 \ + --file "$dockerfile" \ + --tag ${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:"$tag" \ + --tag ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:"$tag" \ + --tag registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:"$tag" \ + --push "$dir" + else + echo "No valid Dockerfile found in $dir" + fi + done + done <<< "${{ steps.meta.outputs.tags }}" \ No newline at end of file