Enhance CI Workflow: Check for Version Bump and appVersion Changes #3
Workflow file for this run
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
name: Check for Version Bump and appVersion in Chart.yaml | |
on: | |
pull_request: | |
types: [opened, synchronize, labeled] | |
jobs: | |
check_version_bump: | |
name: Version Bump Check | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main # Ensure the main branch is fetched | |
- name: Fetch the latest from the main branch | |
run: git fetch origin main | |
- 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 main | |
- name: Check for appVersion changes | |
if: ${{ !contains(github.event.pull_request.labels.*.name, 'release') }} | |
run: | | |
if git diff origin/main -- 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." |