-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
27 lines (21 loc) · 1.02 KB
/
Makefile
File metadata and controls
27 lines (21 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
.PHONY: help changed-images list-images list-images-json
SHELL := /bin/bash
# Find all directories containing a Containerfile
IMAGES := $(shell find . -maxdepth 2 -name Containerfile -printf '%h\n' | cut -d'/' -f2 | sort -u)
help:
@echo "Available targets:"
@echo " list-images - List all image directories (one per line)"
@echo " list-images-json - List all image directories as JSON array"
@echo " changed-images - List images with changes since HEAD~1 as JSON array"
# List images with changes since HEAD~1 as JSON array
changed-images:
@changed=$$(git diff --name-only HEAD~1 HEAD 2>/dev/null | cut -d'/' -f1 | sort -u); \
for img in $(IMAGES); do \
echo "$$changed" | grep -qx "$$img" && echo "$$img"; \
done | jq -R -s -c 'split("\n") | map(select(length > 0))'
# List all image directories (one per line)
list-images:
@for img in $(IMAGES); do echo "$$img"; done
# List all image directories as JSON array
list-images-json:
@echo '$(IMAGES)' | tr ' ' '\n' | jq -R -s -c 'split("\n") | map(select(length > 0))'