Skip to content
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

chore(ci): improve scripts #1139

Merged
merged 1 commit into from
Aug 29, 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
4 changes: 2 additions & 2 deletions .github/scripts/enforce-trusted-registries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ function enforceTrustedImages() {
fi
}

if [[ "$#" == 1 ]] && [[ -d "$1" ]]; then
if [[ "$#" == 1 && -d "$1" ]]; then
enforceTrustedImages "$1"
else
result=0
for chart in charts/*; do
[[ "$chart" == "charts/*" ]] && continue
[[ -d "$chart" ]] || continue

if ! enforceTrustedImages "$chart"; then
result=1
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/extract-artifacthub-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getImages() {
local chart="$1"
local tmpDir
tmpDir="$(mktemp -d -p "$TMP_DIR")"
if [[ -v 2 ]] && [[ -n "$2" ]]; then
if [[ -v 2 && -n "$2" ]]; then
cp -r "$2/artifacthub-values" "$tmpDir/helmRelease"
else
"$(dirname "$0")/templateLocalHelmChart" -1 "$chart" >"$tmpDir/helmRelease.yaml"
Expand Down Expand Up @@ -77,14 +77,14 @@ if [[ "$#" -ge 1 ]]; then
echo "There is no 'artifacthub-values.yaml' in 'charts/$1/ci', exiting" >&2
exit 1
fi
if [[ -v 2 ]] && ! [[ -d "$2/artifacthub-values" ]]; then
if [[ -v 2 && ! -d "$2/artifacthub-values" ]]; then
echo "Missing artifacthub-values directory '$2', exiting" >&2
exit 1
fi
updateChartYaml "$1" "${2:-}"
else
for chart in charts/*; do
[[ "$chart" == "charts/*" ]] && continue
[[ -d "$chart" ]] || continue
[[ -f "$chart/ci/artifacthub-values.yaml" ]] || continue

if yq -e '.type == "library"' "$chart/Chart.yaml" >/dev/null; then
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/sync-codeowners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

echo "* @teutonet/k8s"

for DIR in ./charts/*; do
[[ "$DIR" = "./charts/*" ]] && continue
for DIR in charts/*; do
[[ -f "$DIR/Chart.yaml" ]] || continue
FILE="$DIR/Chart.yaml"
DIR="${DIR//\./}"
MAINTAINERS="$(yq e '.maintainers.[].name' "$FILE" | sed 's/^/@/' | sort --ignore-case | tr '\r\n' ' ')"
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/templateHelmChartRecursivelyToFolder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ targetDir=${2?You need to provide the target directory}

if yq -e '.type == "library"' "$chart/Chart.yaml" >/dev/null; then
echo "Skipping library chart '$chart'" >&2
[[ -v GITHUB_OUTPUT ]] && [[ -f "$GITHUB_OUTPUT" ]] && echo "skipped=true" | tee -a "$GITHUB_OUTPUT"
[[ -v GITHUB_OUTPUT && -f "$GITHUB_OUTPUT" ]] && echo "skipped=true" | tee -a "$GITHUB_OUTPUT"
exit 0
else
[[ -v GITHUB_OUTPUT ]] && [[ -f "$GITHUB_OUTPUT" ]] && echo "skipped=false" | tee -a "$GITHUB_OUTPUT"
[[ -v GITHUB_OUTPUT && -f "$GITHUB_OUTPUT" ]] && echo "skipped=false" | tee -a "$GITHUB_OUTPUT"
fi

[[ ! -d "$targetDir" ]] && mkdir -p "$targetDir"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-artifacthub-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
(
echo -n charts=
for chart in charts/*; do
if [[ "$chart" != "charts/*" ]] && [[ -f "$chart/ci/artifacthub-values.yaml" ]]; then
if [[ "$chart" != "charts/*" && -f "$chart/ci/artifacthub-values.yaml" ]]; then
echo "$chart"
fi
done | cut -d / -f 2 | jq -c -Rn '[inputs]'
Expand Down