Skip to content

Commit

Permalink
Merge pull request #635 from naher94/naher94-patch-3
Browse files Browse the repository at this point in the history
Update version-check.yml
  • Loading branch information
naher94 authored Feb 13, 2024
2 parents c5b5cc3 + ee07582 commit e5b1326
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Version Check

on: workflow_dispatch
on:
pull_request:
types:
- synchronize
- opened
- reopened
- edited
- closed

jobs:
check-version:
Expand All @@ -9,17 +16,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Check version increment
- name: Get default branch
run: |
#!/bin/bash
# Get the base commit SHA (where the branch started)
BASE_SHA=$(git merge-base origin/main $GITHUB_SHA)
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 $BASE_SHA $GITHUB_SHA | grep -q 'config.yml'; then
if git diff --name-only $DEFAULT_BRANCH HEAD | grep -q 'config.yml'; then
# Check if the version was incremented
if git diff $BASE_SHA $GITHUB_SHA 'config.yml' | grep -E '^\+[[:space:]]+version:[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+'; then
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."
Expand Down

0 comments on commit e5b1326

Please sign in to comment.