From 2f5f34145471765b0d73372e0f015828f417cdfb Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 31 Jul 2022 13:54:01 +0300 Subject: [PATCH] fix(ci): use go-yq (#3351) * migrato to python yq * fix(ci): use go-yq * only update sources if dep are installed * bump dev container --- .github/scripts/gen-docs.sh | 46 +++++++++++++++------------ .github/workflows/catalog-test.yaml | 2 +- .github/workflows/charts-release.yaml | 2 +- tools/build-release.sh | 46 +++++++++++++++------------ 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/.github/scripts/gen-docs.sh b/.github/scripts/gen-docs.sh index 84896b873cc..4a43cc8ceec 100755 --- a/.github/scripts/gen-docs.sh +++ b/.github/scripts/gen-docs.sh @@ -32,27 +32,31 @@ sync_tag() { sed -i -e "s|icon: .*|icon: https:\/\/truecharts.org\/img\/chart-icons\/${chartname}.png|" "${chart}/Chart.yaml" echo "Updating home of ${chartname}..." sed -i -e "s|home: .*|home: https:\/\/truecharts.org\/docs\/charts\/${train}\/${chartname}|" "${chart}/Chart.yaml" - echo "Updating sources of ${chartname}..." - yq -V - # Get all sources (except truecharts) - curr_sources=$(yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml") - echo "${chartname}: $curr_sources" - echo "${chartname}: After getting all sources" - cat "${chart}/Chart.yaml" - # Empty sources list in-place - yq -yi 'del(.sources.[])' "${chart}/Chart.yaml" - echo "${chartname}: After deleting all sources" - cat "${chart}/Chart.yaml" - # Add truechart source - tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" yq -yi '.sources += env(tcsource)' "${chart}/Chart.yaml" - echo "${chartname}: After adding tc source" - cat "${chart}/Chart.yaml" - # Add the rest of the sources - while IFS= read -r line; do - src="$line" yq -yi '.sources += env(src)' "${chart}/Chart.yaml" - done <<< "$curr_sources" - echo "${chartname}: After adding the rest of the sources" - cat "${chart}/Chart.yaml" + echo "Attempting to update sources of ${chartname}..." + # Only update source if go-yq is installed + if [ $(command -v go-yq) ]; then + go-yq -V + # Get all sources (except truecharts) + curr_sources=$(go-yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml") + echo "${chartname}: $curr_sources" + echo "${chartname}: After getting all sources" + cat "${chart}/Chart.yaml" + # Empty sources list in-place + go-yq -i 'del(.sources.[])' "${chart}/Chart.yaml" + echo "${chartname}: After deleting all sources" + cat "${chart}/Chart.yaml" + # Add truechart source + tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" go-yq -i '.sources += env(tcsource)' "${chart}/Chart.yaml" + echo "${chartname}: After adding tc source" + cat "${chart}/Chart.yaml" + # Add the rest of the sources + while IFS= read -r line; do + src="$line" go-yq -i '.sources += env(src)' "${chart}/Chart.yaml" + done <<< "$curr_sources" + echo "${chartname}: After adding the rest of the sources" + cat "${chart}/Chart.yaml" + echo "Sources of ${chartname} updated!" + fi; } export -f sync_tag diff --git a/.github/workflows/catalog-test.yaml b/.github/workflows/catalog-test.yaml index c9244b5c5c6..1a1437f5780 100644 --- a/.github/workflows/catalog-test.yaml +++ b/.github/workflows/catalog-test.yaml @@ -15,7 +15,7 @@ jobs: name: Test SCALE Catalog runs-on: ubuntu-latest container: - image: ghcr.io/truecharts/devcontainer:v2.4.0@sha256:395ee7ed8b9cba6569ddeba77b7ceb86fdb79b91a19c639625d7bc54cb1ccc1d + image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:395ee7ed8b9cba6569ddeba77b7ceb86fdb79b91a19c639625d7bc54cb1ccc1d steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 name: Checkout diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index c7335ebe22f..f85097d9b4f 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -14,7 +14,7 @@ jobs: release: runs-on: ubuntu-latest container: - image: ghcr.io/truecharts/devcontainer:v2.4.0@sha256:395ee7ed8b9cba6569ddeba77b7ceb86fdb79b91a19c639625d7bc54cb1ccc1d + image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:395ee7ed8b9cba6569ddeba77b7ceb86fdb79b91a19c639625d7bc54cb1ccc1d concurrency: gitpush steps: - name: Install Kubernetes tools diff --git a/tools/build-release.sh b/tools/build-release.sh index 1d74d633e53..4bc6d925532 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -301,27 +301,31 @@ sync_tag() { sed -i -e "s|icon: .*|icon: https:\/\/truecharts.org\/img\/chart-icons\/${chartname}.png|" "${chart}/Chart.yaml" echo "Updating home of ${chartname}..." sed -i -e "s|home: .*|home: https:\/\/truecharts.org\/docs\/charts\/${train}\/${chartname}|" "${chart}/Chart.yaml" - echo "Updating sources of ${chartname}..." - yq -V - # Get all sources (except truecharts) - curr_sources=$(yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml") - echo "${chartname}: $curr_sources" - echo "${chartname}: After getting all sources" - cat "${chart}/Chart.yaml" - # Empty sources list in-place - yq -yi 'del(.sources.[])' "${chart}/Chart.yaml" - echo "${chartname}: After deleting all sources" - cat "${chart}/Chart.yaml" - # Add truechart source - tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" yq -yi '.sources += env(tcsource)' "${chart}/Chart.yaml" - echo "${chartname}: After adding tc source" - cat "${chart}/Chart.yaml" - # Add the rest of the sources - while IFS= read -r line; do - src="$line" yq -yi '.sources += env(src)' "${chart}/Chart.yaml" - done <<< "$curr_sources" - echo "${chartname}: After adding the rest of the sources" - cat "${chart}/Chart.yaml" + echo "Attempting to update sources of ${chartname}..." + # Only update source if go-yq is installed + if [ $(command -v go-yq) ]; then + go-yq -V + # Get all sources (except truecharts) + curr_sources=$(go-yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml") + echo "${chartname}: $curr_sources" + echo "${chartname}: After getting all sources" + cat "${chart}/Chart.yaml" + # Empty sources list in-place + go-yq -i 'del(.sources.[])' "${chart}/Chart.yaml" + echo "${chartname}: After deleting all sources" + cat "${chart}/Chart.yaml" + # Add truechart source + tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" go-yq -i '.sources += env(tcsource)' "${chart}/Chart.yaml" + echo "${chartname}: After adding tc source" + cat "${chart}/Chart.yaml" + # Add the rest of the sources + while IFS= read -r line; do + src="$line" go-yq -i '.sources += env(src)' "${chart}/Chart.yaml" + done <<< "$curr_sources" + echo "${chartname}: After adding the rest of the sources" + cat "${chart}/Chart.yaml" + echo "Sources of ${chartname} updated!" + fi; } export -f sync_tag