-
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (63 loc) · 2.61 KB
/
validator.yml
File metadata and controls
77 lines (63 loc) · 2.61 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Validate Application PR
on:
pull_request:
branches:
- apply
types: [opened, synchronize, reopened, edited]
jobs:
validate-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate PR title format
id: validate-title
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
PATTERN="^Application for OpenStack by .+$"
if [[ ! "$PR_TITLE" =~ $PATTERN ]]; then
echo "❌ PR title does not match the required format"
echo "Expected format: 'Application for OpenStack by [username]'"
echo "Current title: '$PR_TITLE'"
exit 1
fi
echo "✅ PR title format is valid"
echo "title_valid=true" >> $GITHUB_OUTPUT
- name: Get changed files
id: changed-files
run: |
# Get the list of changed files in the PR
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
# Count the number of changed files
FILE_COUNT=$(echo "$CHANGED_FILES" | grep -v '^$' | wc -l | tr -d ' ')
echo "Changed files:"
echo "$CHANGED_FILES"
echo "file_count=$FILE_COUNT" >> $GITHUB_OUTPUT
echo "changed_files<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Validate only members.json is changed
run: |
CHANGED_FILES="${{ steps.changed-files.outputs.changed_files }}"
FILE_COUNT="${{ steps.changed-files.outputs.file_count }}"
if [ "$FILE_COUNT" -ne 1 ]; then
echo "❌ Expected exactly 1 file to be changed, but found $FILE_COUNT file(s)"
echo "Changed files:"
echo "$CHANGED_FILES"
exit 1
fi
if [ "$CHANGED_FILES" != "members.json" ]; then
echo "❌ Expected only 'members.json' to be changed, but found: '$CHANGED_FILES'"
exit 1
fi
echo "✅ Only members.json is changed"
- name: PR validation summary
run: |
echo "## ✅ PR Validation Passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- ✅ PR title format is correct" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Only members.json is changed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**PR Title:** ${{ github.event.pull_request.title }}" >> $GITHUB_STEP_SUMMARY