Skip to content

Update version-check.yml #29

Update version-check.yml

Update version-check.yml #29

Workflow file for this run

name: Version Check
on:
pull_request:
types:
- synchronize
- opened
- reopened
- edited
- closed
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get default branch
run: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
echo "Default branch is: $DEFAULT_BRANCH"
- name: Check version increment
run: |
# Print the list of all changed files for debugging
echo "All changed files in this pull request:"
git diff --name-only $DEFAULT_BRANCH HEAD
# Check if '_config.yml' was modified in this pull request
if git diff --name-only $DEFAULT_BRANCH HEAD | grep -q -E '^_config\.yml$'; then
# Print the changes in '_config.yml' for debugging
echo "Changes in '_config.yml':"
git diff HEAD^..HEAD '_config.yml'
# Check if the version was incremented
if git diff HEAD^..HEAD '_config.yml' | grep -E '^\+[[:space:]]+version:[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+'; then
echo "Version incremented. Check passed."
else
echo "Error: Version in '_config.yml' was not incremented. Please update the version before merging."
exit 1
fi
else
echo "Error: '_config.yml' not modified in this pull request. Please make changes to '_config.yml' before merging."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}