packer-images/ci/build.sh
Ben Vincent f497194dda feat: update actions container
- cleanup TAGS/PUSH make targets
- update actionsdind to include consul, packer, terraform, terragrunt and vault
- add script to build only images that changed, or all if build/ scripts are changed
2025-01-12 13:28:06 +11:00

32 lines
1003 B
Bash
Executable File

#!/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/')
# Run `make all` if there are changes in builds/
if [ -n "$builds_changes" ]; then
echo "Changes detected in builds/. Running 'make build-all'..."
make build-all
fi
# Run specific `make` commands for each changed file in images/
if [ -n "$images_changes" ]; then
echo "Changes detected in images/. Running specific 'make' commands..."
# Extract unique paths for `make` commands
for file in $images_changes; do
# Get the subdirectory path for the make command (e.g., almalinux/8.10/actionsdind)
target=$(echo "$file" | sed -E 's|images/||; s|/[^/]+$||')
echo "Running 'make $target'..."
make "$target"
done
fi
# If no changes, output a message
if [ -z "$builds_changes" ] && [ -z "$images_changes" ]; then
echo "No relevant changes detected."
fi