From 0a30ee902d62ccabff7aeef2ea444c362847c029 Mon Sep 17 00:00:00 2001 From: Matthew Sevey Date: Wed, 3 Apr 2024 15:36:41 -0400 Subject: [PATCH] fix(ci): update logic check in reuseable pipeline (#99) --- .../workflows/reusable_dockerfile_pipeline.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable_dockerfile_pipeline.yml b/.github/workflows/reusable_dockerfile_pipeline.yml index 1a1da6c..ef8823a 100644 --- a/.github/workflows/reusable_dockerfile_pipeline.yml +++ b/.github/workflows/reusable_dockerfile_pipeline.yml @@ -113,8 +113,9 @@ jobs: # yamllint enable # Log the key inputs to the logic as well a the outputs. We check that - # build_for_pr and build_for_merge are never equal as that would indicate a - # bug. + # build_for_pr and build_for_merge are never equal when they are true as that + # would indicate a bug. If they are both false, this is ok, as this is the + # case on pushing commits to a PR. logic-check: needs: prepare-env runs-on: "ubuntu-latest" @@ -129,7 +130,9 @@ jobs: echo "build_for_merge: ${{ needs.prepare-env.outputs.build_for_merge }}" echo "not_a_fork: ${{ needs.prepare-env.outputs.not_a_fork }}" - name: Check logic - if: ${{ needs.prepare-env.outputs.build_for_pr == needs.prepare-env.outputs.build_for_merge }} + if: | + (needs.prepare-env.outputs.build_for_pr == needs.prepare-env.outputs.build_for_merge) + && needs.prepare-env.outputs.build_for_pr != 'false' run: | echo "Failing step due to build_for_pr == build_for_merge" exit 1 @@ -176,6 +179,13 @@ jobs: runs-on: "ubuntu-latest" # wait until the jobs are finished. needs: ["prepare-env", "logic-check", "docker-security"] + # We only want to run this step if one of the build flags is true. We don't + # run if both logic flags are false. This is the case for push events on PR + # commits. The logic-check job protects us from the case of both build flags + # being equal to true. + if: | + needs.prepare-env.outputs.build_for_pr == 'true' + || needs.prepare-env.outputs.build_for_merge == 'true' permissions: contents: write packages: write