-
Notifications
You must be signed in to change notification settings - Fork 58
31 lines (25 loc) · 1.14 KB
/
spec-validate-pr.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
name: Conditional Specification Validation
on:
pull_request:
paths:
- '**/resources/schema/**/*.json'
jobs:
validate_json_and_commit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Validate Changes and Commit Message
run: |
# Check for changes in specification files inside the resources folder
changed_files=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }})
# Fetch the commit messages from the PR
commit_messages=$(git log --pretty=oneline ${{ github.base_ref }}..${{ github.head_ref }})
# Check if any commit message contains a specific keyword or pattern (e.g., "RTC")
if echo "$commit_messages" | grep -q 'RTC' && echo "$changed_files" | grep -E 'resources/schema/.*\.json$'; then
echo "Commit message contains 'RTC' keyword, and specification files have changed. Build passed."
else
echo "Either commit message doesn't contain 'RTC' keyword or specification files haven't changed. Build failed."
exit 1
fi
shell: bash