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
This commit is contained in:
Ben Vincent 2025-01-12 18:00:35 +11:00
parent 8af68f6dc8
commit d503b0c28d

View File

@ -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