From 8b120891e4a952b6f16accef538a5adf0ecacf7c Mon Sep 17 00:00:00 2001 From: Austin Parker Date: Wed, 11 Oct 2023 11:59:54 -0400 Subject: [PATCH] Fix logic in GHA (#1172) * fix logic * refactor logic * remove extra fi --- .github/workflows/build-images.yml | 21 ++++++++++----------- .github/workflows/checks.yml | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 5c9c9aced3..194d42ad0e 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -15,7 +15,7 @@ on: type: boolean version: description: The version used when tagging the image - default: dev + default: 'dev' required: false type: string @@ -101,23 +101,22 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Check for file changes + - name: Check for changes and set push options id: check_changes - if: ${{ !inputs.push }} run: | DOCKERFILE_DIR=$(dirname ${{ matrix.file_tag.file }}) FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- $DOCKERFILE_DIR) - if [ -z "$FILES_CHANGED" ]; then + FORCE_PUSH=${{ inputs.push }} + if [ "$FORCE_PUSH" = true ]; then + echo "Force push is enabled, proceeding with build." + echo "skip='false'" >> "$GITHUB_OUTPUT" + elif [ -z "$FILES_CHANGED" ]; then echo "No changes in ${{ matrix.file_tag.context }}, skipping build." - echo "skip=true" >> "$GITHUB_OUTPUT" + echo "skip='true'" >> "$GITHUB_OUTPUT" else echo "Changes detected in ${{ matrix.file_tag.context }}, proceeding with build." - echo "skip=false" >> "$GITHUB_OUTPUT" + echo "skip='false'" >> "$GITHUB_OUTPUT" fi - - name: Override skip for push - if: ${{ inputs.push }} - run: echo "skip=false" >> "$GITHUB_OUTPUT" - id: override_skip - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -142,7 +141,7 @@ jobs: [worker.oci] max-parallelism = 2 - name: Matrix Build and push demo images - if: steps.check_changes.outputs.skip == 'false' || steps.override_skip.outputs.skip == 'false' + if: steps.check_changes.outputs.skip == 'false' uses: docker/build-push-action@v3.3.1 with: context: ${{ matrix.file_tag.context }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 78822b00bf..0a0b5adcf0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -14,7 +14,7 @@ jobs: uses: ./.github/workflows/build-images.yml with: push: false - version: dev + version: 'dev' markdownlint: runs-on: ubuntu-latest