From 31ad2f23b4259634a6312604cc8a5f4383546388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= Date: Thu, 10 Aug 2023 18:51:56 +0200 Subject: [PATCH] feat: add a required check on chart version bump --- .../workflows/check-chart-versions-bump.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/check-chart-versions-bump.yml diff --git a/.github/workflows/check-chart-versions-bump.yml b/.github/workflows/check-chart-versions-bump.yml new file mode 100644 index 000000000..115051856 --- /dev/null +++ b/.github/workflows/check-chart-versions-bump.yml @@ -0,0 +1,39 @@ +name: Check if modified chart versions have been bumped +on: + push: null + pull_request: null +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - id: list_modified_folders + name: List modified folders + if: github.ref != 'refs/heads/main' + run: | + # Get the list of modified files and folders + git diff --name-only ${{ github.event.before }} ${{ github.sha }} > changes.txt + + # Extract the unique folder paths + awk -F/ '{print $1}' changes.txt | sort --unique > modified_folders.txt + + # Store the modified folders as a step output + echo "::set-output name=modified_folders::$(cat modified_folders.txt)" + - id: check-bump + name: Check if every modified chart version has been bumped + if: github.ref != 'refs/heads/main' + run: | + # Read the modified folders from the previous step's output + IFS=$'\n' read -d '' -r -a folders <<< "${{ steps.list_modified_folders.outputs.modified_folders }}" + + for folder in "${folders[@]}"; do + MAIN_CHART_VERSION=$(git show origin:charts/"${folder}"/Chart.yaml | grep "^version:") + PR_CHART_VERSION=$(git show ${{ github.event.before }}:charts/"${folder}"/Chart.yaml | grep "^version:") + + if [ "$MAIN_CHART_VERSION" == "$PR_CHART_VERSION" ]; then + echo "ERROR: the version of the '${folder}' chart hasn't been bumped." + exit 1 + fi + + echo "The version of the '${folder}' chart has been bumped." + }