All checks were successful
Build / build (pull_request) Successful in 20m34s
- ensure unkin-ca-certificates are installed - find the default incus remote and use that for images - dont set publish_remote_name - build incus images for the base image - build puppet-base image for incus only - ensure builds are made with the `build` profile - only build 9.5+ for incus - prevent the build system from building images twice
46 lines
1.4 KiB
Bash
Executable File
46 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 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
|
|
echo "Changes detected in builds/. Running 'make all'..."
|
|
make all && exit 0 || exit 1
|
|
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
|
|
TARGETS=$(echo "$images_changes" | sed -E 's|images/||; s|/[^/]+$||' | sort -u)
|
|
|
|
# Prioritize base images first
|
|
BASE_TARGETS=$(echo "$TARGETS" | grep '/base$' || true)
|
|
OTHER_TARGETS=$(echo "$TARGETS" | grep -v '/base$' || true)
|
|
|
|
# Build base images first
|
|
for target in $BASE_TARGETS; do
|
|
echo "Running 'make $target' (base image first)..."
|
|
make "$target"
|
|
done
|
|
|
|
# Then build other images
|
|
for target in $OTHER_TARGETS; do
|
|
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
|