Skip to content

Commit

Permalink
Fix logic in GHA (open-telemetry#1172)
Browse files Browse the repository at this point in the history
* fix logic

* refactor logic

* remove extra fi
  • Loading branch information
austinlparker committed Oct 11, 2023
1 parent 17438b7 commit b4dda8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
type: boolean
version:
description: The version used when tagging the image
default: dev
default: 'dev'
required: false
type: string

Expand Down Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: ./.github/workflows/build-images.yml
with:
push: false
version: dev
version: 'dev'

markdownlint:
runs-on: ubuntu-latest
Expand Down

0 comments on commit b4dda8e

Please sign in to comment.