diff --git a/.github/workflows/build_images_uv.yaml b/.github/workflows/build_images_uv.yaml index 0daa87881..b3de34c4e 100644 --- a/.github/workflows/build_images_uv.yaml +++ b/.github/workflows/build_images_uv.yaml @@ -1,46 +1,59 @@ name: Docker image CI on: - pull_request: - paths: - - "lumigator/**" - - ".github/**" - # synchronized is when you push new commits - types: ["opened", "synchronize"] push: branches: - - main + - "main" + pull_request: + branches: + - "**" # required to enable manual triggers on the GH web ui workflow_dispatch: jobs: - build: + build-image: name: Build Docker image runs-on: ubuntu-latest - steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check modified paths + run: | + if git diff --name-only ${{ github.event.before }} ${{ github.event.pull_request.head.sha }} | grep -E '^lumigator/|^\.github/'; then + echo "Changes detected. Rebuilding image..." + is_image_build_required=true + else + echo "No relevant changes detected." + is_image_build_required=false + fi + echo "is_image_build_required=$is_image_build_required" >> $GITHUB_OUTPUT - name: Get repo version + if: ${{ steps.vars.outputs.is_image_build_required }} run: | echo "REPOVERSION=$(git describe --tags --dirty --match \"[0-9\.]*\" --always)" >> $GITHUB_ENV echo "Version of the repo for this build: $REPOVERSION" - name: Set up QEMU + if: ${{ steps.vars.outputs.is_image_build_required }} uses: docker/setup-qemu-action@v3 - name: Set up Docker buildx + if: ${{ steps.vars.outputs.is_image_build_required }} uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: ${{ steps.vars.outputs.is_image_build_required && github.event_name == 'push' && github.ref == 'refs/heads/main' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push + if: ${{ steps.vars.outputs.is_image_build_required }} uses: docker/build-push-action@v6 with: platforms: linux/amd64,linux/arm64