[bitnami/*] test: fixed bump detection (#9069)

* [bitnami/*] test: fixed bump detection

ref: bitnami/charts#9062 -- The script compared with the head repo, not base; now using data from the API response to detect bumps
Signed-off-by: Marcello Pontes <balaum@gmail.com>

* [bitnami/*] removed extra char on bump detection

Signed-off-by: Marcello Pontes <balaum@gmail.com>
This commit is contained in:
Marcello Pontes
2022-02-22 15:50:00 +01:00
committed by GitHub
parent 42723d2a27
commit 8a68afc4c7

View File

@@ -28,12 +28,13 @@ jobs:
# Using the Github API to detect the files changed as git merge-base stops working when the branch is behind
# and jitterbit/get-changed-files does not support pull_request_target
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
files_changed="$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "$URL" | jq -r '.[] | .filename')"
files_changed_data=$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "$URL" | sed 's/\\/\\\\/g')
files_changed="$(echo $files_changed_data | jq -r '.[] | .filename')"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "bitnami/[^/]*" | sort | uniq || true)"
# Using grep -c as a better alternative to wc -l when dealing with empty strings."
num_charts_changed="$(echo "$charts_dirs_changed" | grep -c "bitnami" || true)"
num_version_bumps="$(echo "$files_changed" | grep Chart.yaml | xargs git diff origin/master | grep -c "+version" || true)"
num_version_bumps="$(echo "$files_changed_data" | jq -r '[.[] | select(.filename|endswith("Chart.yaml")) | select(.patch|contains("+version")) ] | length' )"
if [[ "$num_charts_changed" -ne "$num_version_bumps" ]]; then
# Changes done in charts but version not bumped -> ERROR