Update version-check.yml #14
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: 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: | | |
# Check if 'config.yml' was modified in this pull request | |
if git diff --name-only $DEFAULT_BRANCH HEAD | grep -q 'config.yml'; then | |
# Check if the version was incremented | |
if git diff $DEFAULT_BRANCH 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 # This line triggers a failure by exiting with a non-zero code | |
fi | |
else | |
echo "Error: config.yml not modified in this pull request. Please make changes to config.yml before merging." | |
exit 1 # This line triggers a failure by exiting with a non-zero code | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |