-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): check version for bump in PRs
- Loading branch information
1 parent
d2bac1e
commit 1f154e3
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Check for version bumps in PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
check_changes_and_versions: | ||
name: Check for changes and version bumps | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.MATRIX }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Verify changes and versions | ||
run: | | ||
GIT_DIFF_BASE='${{ github.event.pull_request.base.sha }}' | ||
GIT_DIFF_HEAD='${{ github.event.pull_request.head.sha }}' | ||
./scripts/ci_version_changed_check.sh "$GIT_DIFF_BASE" "$GIT_DIFF_HEAD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
GIT_DIFF_BASE="$1" | ||
GIT_DIFF_HEAD="$2" | ||
EXIT_CODE=0 | ||
CHANGED=0 | ||
|
||
[ -z "$GIT_DIFF_BASE" -o -z "$GIT_DIFF_HEAD" ] && | ||
echo "GIT_DIFF_BASE or GIT_DIFF_HEAD not provided. Exiting." && | ||
exit 1 | ||
|
||
cd charts | ||
|
||
for d in * ; do | ||
# check if directory changed and skip if not | ||
git diff -s --exit-code "${GIT_DIFF_BASE}..${GIT_DIFF_HEAD}" -- "$d" && \ | ||
continue | ||
CHANGED=1 | ||
echo "[Chart $d]: files changed, checking versions" | ||
|
||
chart_yaml="./$d/Chart.yaml" | ||
if [ -f "$chart_yaml" ] ; then | ||
base_ver="$(git show "$GIT_DIFF_BASE:$chart_yaml" | grep "^version:" | awk '{print $2}')" | ||
echo "[Chart $d]: base version: $base_ver" | ||
head_ver="$(git show "$GIT_DIFF_HEAD:$chart_yaml" | grep "^version:" | awk '{print $2}')" | ||
echo "[Chart $d]: head version: $head_ver" | ||
|
||
if [ "$base_ver" == "$head_ver" ] ; then | ||
echo -e "[Chart $d]: \e[31mversion not changed, this should be fixed!\e[0m" | ||
EXIT_CODE=2 | ||
else | ||
echo -e "[Chart $d]: \e[32mversion changed, everything is ok!\e[0m" | ||
fi | ||
fi | ||
done | ||
|
||
[ "$CHANGED" == "0" ] && \ | ||
echo -e "\e[32mNo chart changes detected, everything is ok!\e[0m" | ||
exit $EXIT_CODE |