Skip to content

Commit

Permalink
Update version-check.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
naher94 authored Feb 13, 2024
1 parent d9d0398 commit 4d6849c
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- opened
- reopened
- edited
- closed

jobs:
check-version:
Expand All @@ -16,25 +15,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Get default branch
- name: Print changed files
run: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
echo "Default branch is: $DEFAULT_BRANCH"
echo "Changed files in this pull request:"
git show --name-only --pretty="" ${{ github.event.before }} ${{ github.sha }}
- 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
if git show --name-only --pretty="" ${{ github.event.before }} ${{ github.sha }} | grep -q -E '^_config\.yml$'; then
echo "Changes in '_config.yml':"
git diff HEAD^..HEAD '_config.yml'
git diff ${{ github.event.before }} ${{ github.sha }} '_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
if git diff ${{ github.event.before }} ${{ github.sha }} '_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."
Expand All @@ -46,5 +38,3 @@ jobs:
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


0 comments on commit 4d6849c

Please sign in to comment.