File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff 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 }}
Original file line number Diff line number Diff line change @@ -4,21 +4,37 @@ set -eux
44
55build_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
1834git 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
2339base_ref_build_dir=" $build_dir /$INPUT_BASE_REF "
2440head_ref_build_dir=" $build_dir /$INPUT_HEAD_REF "
Original file line number Diff line number Diff line change 1+ The point of this folder is to test that if the base commit does not contain this folder, the action is still successful
Original file line number Diff line number Diff line change 1+ apiVersion : kustomize.config.k8s.io/v1beta1
2+ kind : Kustomization
3+ resources :
4+ - ../base
You can’t perform that action at this time.
0 commit comments