Skip to content

Commit 8b12089

Browse files
Fix logic in GHA (#1172)
* fix logic * refactor logic * remove extra fi
1 parent fc01d8f commit 8b12089

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.github/workflows/build-images.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
type: boolean
1616
version:
1717
description: The version used when tagging the image
18-
default: dev
18+
default: 'dev'
1919
required: false
2020
type: string
2121

@@ -101,23 +101,22 @@ jobs:
101101
- uses: actions/checkout@v3
102102
with:
103103
fetch-depth: 0
104-
- name: Check for file changes
104+
- name: Check for changes and set push options
105105
id: check_changes
106-
if: ${{ !inputs.push }}
107106
run: |
108107
DOCKERFILE_DIR=$(dirname ${{ matrix.file_tag.file }})
109108
FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- $DOCKERFILE_DIR)
110-
if [ -z "$FILES_CHANGED" ]; then
109+
FORCE_PUSH=${{ inputs.push }}
110+
if [ "$FORCE_PUSH" = true ]; then
111+
echo "Force push is enabled, proceeding with build."
112+
echo "skip='false'" >> "$GITHUB_OUTPUT"
113+
elif [ -z "$FILES_CHANGED" ]; then
111114
echo "No changes in ${{ matrix.file_tag.context }}, skipping build."
112-
echo "skip=true" >> "$GITHUB_OUTPUT"
115+
echo "skip='true'" >> "$GITHUB_OUTPUT"
113116
else
114117
echo "Changes detected in ${{ matrix.file_tag.context }}, proceeding with build."
115-
echo "skip=false" >> "$GITHUB_OUTPUT"
118+
echo "skip='false'" >> "$GITHUB_OUTPUT"
116119
fi
117-
- name: Override skip for push
118-
if: ${{ inputs.push }}
119-
run: echo "skip=false" >> "$GITHUB_OUTPUT"
120-
id: override_skip
121120
- name: Log in to the Container registry
122121
uses: docker/login-action@v3
123122
with:
@@ -142,7 +141,7 @@ jobs:
142141
[worker.oci]
143142
max-parallelism = 2
144143
- name: Matrix Build and push demo images
145-
if: steps.check_changes.outputs.skip == 'false' || steps.override_skip.outputs.skip == 'false'
144+
if: steps.check_changes.outputs.skip == 'false'
146145
uses: docker/[email protected]
147146
with:
148147
context: ${{ matrix.file_tag.context }}

.github/workflows/checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: ./.github/workflows/build-images.yml
1515
with:
1616
push: false
17-
version: dev
17+
version: 'dev'
1818

1919
markdownlint:
2020
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)