Skip to content

Commit

Permalink
feat: add a required check on chart version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed Aug 10, 2023
1 parent 2aff68e commit 31ad2f2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/check-chart-versions-bump.yml
Original file line number Diff line number Diff line change
@@ -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."
}

0 comments on commit 31ad2f2

Please sign in to comment.