Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance CI Workflow: Check for Version Bump and appVersion Changes #44

Merged
46 changes: 46 additions & 0 deletions .github/workflows/check-version-bump.yml
Fovty marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Check for Version Bump and appVersion in Chart.yaml
Fovty marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
types: [opened, synchronize, labeled]

jobs:
check_version_bump:
name: Version Bump Check
Fovty marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract Chart appVersion
id: extract_appversion
run: |
appversion=$(yq e '.appVersion' ./deployments/chart/Chart.yaml)
echo "appversion=$appversion" >> $GITHUB_ENV

# Check for changes in the appVersion between PR and base branch
- name: Check for appVersion changes
if: ${{ !contains(github.event.pull_request.labels.*.name, 'release') }}
run: |
echo "Checking for appVersion changes..."
if git diff origin/${{ github.base_ref }} -- deployments/chart/Chart.yaml | grep -qe "^[+-]appVersion: "; then
echo "appVersion has changed. Failing the job."
exit 1
else
echo "No appVersion changes detected."
fi

# Post warning comment if there is a failure
- name: Post warning comment
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: "⚠️ Warning: This PR will result in a new release because the `appVersion` in Chart.yaml has changed to `${{ env.appversion }}`. Please confirm before merging."