-
Notifications
You must be signed in to change notification settings - Fork 4
32 lines (27 loc) · 1.06 KB
/
version-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Version Check
on: workflow_dispatch
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check version increment
run: |
#!/bin/bash
# Get the base commit SHA (where the branch started)
BASE_SHA=$(git merge-base gh-pages $GITHUB_SHA)
# Check if 'config.yml' was modified in this pull request
if git diff --name-only $BASE_SHA $GITHUB_SHA | 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
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 "config.yml not modified. Skipping version check."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}