Skip to content

Commit df4080d

Browse files
authored
Merge pull request #3 from supplypike/SRENEW-2465
SRENEW-2465 | fix to allow new kustomizations
2 parents c24e559 + 366e0da commit df4080d

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ jobs:
1515
uses: ./
1616
with:
1717
base_ref: 027b33661ae3211230e8cd03d19df49ba620b379
18-
head_ref: 182a672418c5bae4d6b7ca1244da5f28bf5ff6f0
18+
head_ref: ${{ github.sha }}
1919
kustomizations: |-
2020
testdata/prod
2121
testdata/stage
22+
testdata/new
2223
- uses: mshick/add-pr-comment@v2
2324
with:
2425
message: ${{ steps.test-action.outputs.diff }}

entrypoint.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,37 @@ set -eux
44

55
build_dir=$(mktemp -d)
66

7-
build() {
8-
ref="$1"
9-
git checkout "$1" --quiet
7+
build_base() {
8+
ref="$INPUT_BASE_REF"
9+
git checkout "$ref" --quiet
1010

1111
for target in $INPUT_KUSTOMIZATIONS; do
12-
echo "Building $target" to "$build_dir/$ref/$target"
12+
echo "Building base $target" to "$build_dir/$ref/$target"
13+
mkdir -p "$build_dir/$ref/$target"
14+
if [ ! -d "$target" ]; then
15+
echo "Base $target does not exist. Treating it as an empty dir"
16+
mkdir -p "$target"
17+
else
18+
kustomize build "$target" -o "$build_dir/$ref/$target/"
19+
fi
20+
done
21+
}
22+
23+
build_head() {
24+
ref="$INPUT_HEAD_REF"
25+
git checkout "$ref" --quiet
26+
27+
for target in $INPUT_KUSTOMIZATIONS; do
28+
echo "Building head $target" to "$build_dir/$ref/$target"
1329
mkdir -p "$build_dir/$ref/$target"
1430
kustomize build "$target" -o "$build_dir/$ref/$target/"
1531
done
1632
}
1733

1834
git config --global --add safe.directory "$GITHUB_WORKSPACE"
1935

20-
build "$INPUT_BASE_REF"
21-
build "$INPUT_HEAD_REF"
36+
build_base
37+
build_head
2238

2339
base_ref_build_dir="$build_dir/$INPUT_BASE_REF"
2440
head_ref_build_dir="$build_dir/$INPUT_HEAD_REF"

testdata/new/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The point of this folder is to test that if the base commit does not contain this folder, the action is still successful

testdata/new/kustomization.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../base

0 commit comments

Comments
 (0)