From d503b0c28d297f021aaaecabd1bcc51e8d0a458a Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 12 Jan 2025 18:00:35 +1100 Subject: [PATCH] fix: ensure build.sh find correct changed files (#5) - ensure the build.sh script finds the changed files for the master branch or others Reviewed-on: https://git.query.consul/unkin/packer-images/pulls/5 --- ci/build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 8e34e4d..f8be9e2 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,10 +1,13 @@ #!/bin/bash -# Check for changes in builds/ folder -builds_changes=$(git diff --name-only master | grep -E '^builds/') - -# Check for changes in images/ folder -images_changes=$(git diff --name-only master | grep -E '^images/') +# Check for changes in images/ folder and the builds/ folder +if [ "$(git branch --show-current)" = "master" ]; then + builds_changes=$(git diff --name-only HEAD^...master | grep -E '^builds/') + images_changes=$(git diff --name-only HEAD^...master | grep -E '^images/') +else + builds_changes=$(git diff --name-only master | grep -E '^builds/') + images_changes=$(git diff --name-only master | grep -E '^images/') +fi # Run `make all` if there are changes in builds/ if [ -n "$builds_changes" ]; then