Skip to content

SRENEW-2465 | fix to allow new kustomizations #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ jobs:
uses: ./
with:
base_ref: 027b33661ae3211230e8cd03d19df49ba620b379
head_ref: 182a672418c5bae4d6b7ca1244da5f28bf5ff6f0
head_ref: ${{ github.sha }}
kustomizations: |-
testdata/prod
testdata/stage
testdata/new
- uses: mshick/add-pr-comment@v2
with:
message: ${{ steps.test-action.outputs.diff }}
28 changes: 22 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,37 @@ set -eux

build_dir=$(mktemp -d)

build() {
ref="$1"
git checkout "$1" --quiet
build_base() {
ref="$INPUT_BASE_REF"
git checkout "$ref" --quiet

for target in $INPUT_KUSTOMIZATIONS; do
echo "Building $target" to "$build_dir/$ref/$target"
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 "$INPUT_BASE_REF"
build "$INPUT_HEAD_REF"
build_base
build_head

base_ref_build_dir="$build_dir/$INPUT_BASE_REF"
head_ref_build_dir="$build_dir/$INPUT_HEAD_REF"
Expand Down
1 change: 1 addition & 0 deletions testdata/new/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The point of this folder is to test that if the base commit does not contain this folder, the action is still successful
4 changes: 4 additions & 0 deletions testdata/new/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base