-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·68 lines (52 loc) · 1.5 KB
/
entrypoint.sh
File metadata and controls
executable file
·68 lines (52 loc) · 1.5 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
set -eux
build_dir=$(mktemp -d)
build_base() {
ref="$INPUT_BASE_REF"
git checkout "$ref" --quiet
for target in $INPUT_KUSTOMIZATIONS; do
echo "Building base $target" to "$build_dir/$ref/$target"
mkdir -p "$build_dir/$ref/$target"
if [ ! -d "$target" ]; then
echo "Base $target does not exist. Treating it as an empty dir"
mkdir -p "$target"
else
kustomize build "$target" -o "$build_dir/$ref/$target/"
fi
done
}
build_head() {
ref="$INPUT_HEAD_REF"
git checkout "$ref" --quiet
for target in $INPUT_KUSTOMIZATIONS; do
echo "Building head $target" to "$build_dir/$ref/$target"
mkdir -p "$build_dir/$ref/$target"
kustomize build "$target" -o "$build_dir/$ref/$target/"
done
}
git config --global --add safe.directory "$GITHUB_WORKSPACE"
build_base
build_head
base_ref_build_dir="$build_dir/$INPUT_BASE_REF"
head_ref_build_dir="$build_dir/$INPUT_HEAD_REF"
set +e
for target in $INPUT_KUSTOMIZATIONS; do
diffoscope "$base_ref_build_dir/$target" "$head_ref_build_dir/$target" \
--markdown - \
--exclude-directory-metadata=yes | tee -a diff.md
done
set -e
# Formatting hacks
output=$(cat diff.md | sed "s|$base_ref_build_dir/||" | sed '/Comparing/ s/&.*$//' | sed "s|^#\{2,\} Comparing| Comparing|" | sed "s|^# Comparing|## Comparing|")
if [ ${#output} -gt 65535 ]; then
output="Kustomize diff too large to display"
fi
if [ -z "$output" ]; then
output="Kustomize diff did not find any differences"
fi
{
echo 'diff<<EOF'
echo "$output"
echo 'EOF'
} >>"$GITHUB_OUTPUT"
exit 0