From 9860fe79725f1b797873207b844364392f77b303 Mon Sep 17 00:00:00 2001 From: Tim Gu Date: Thu, 6 Feb 2025 12:50:09 -0500 Subject: [PATCH] Added Docker CI --- .github/workflows/build_docker.yml | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build_docker.yml diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 00000000..b6f37380 --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,56 @@ +name: Build Docker +on: + push: + branches: [ develop, release/** ] + paths: + - 'Dockerfiles/**' + - '.github/workflows/**' + pull_request: + branches: [ develop, release/** ] + paths: + - 'Dockerfiles/**' + - '.github/workflows/**' + +jobs: + find-dockerfiles: + name: Find Dockerfiles + runs-on: self-hosted + outputs: + files: ${{ steps.find-files.outputs.files }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Find Dockerfiles + id: find-files + run: | + echo "## Finding all Dockerfiles in the 'Dockerfiles/' directory" + FILES=$(find Dockerfiles/ -type f -printf "%f\n" | grep .*Dockerfile) + echo "Found Dockerfiles:" + echo "$FILES" + # Convert the array to JSON array + JSON_ARRAY=$(printf '%s\n' "${FILES[@]}" | jq -R . | jq -s . | jq -c .) + echo "JSON_ARRAY is" + echo $JSON_ARRAY + echo "files=$JSON_ARRAY" >> $GITHUB_OUTPUT + build: + name: Build Docker Images + runs-on: self-hosted + needs: find-dockerfiles + strategy: + matrix: + file: ${{fromJson(needs.find-dockerfiles.outputs.files)}} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build Docker image for ${{matrix.file}} + uses: docker/build-push-action@v4 + with: + context: Dockerfiles/ + file: Dockerfiles/${{matrix.file}} + push: false + tags: rocm-examples/dockerci:latest +