forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (107 loc) · 3.95 KB
/
pr-format.yml
File metadata and controls
124 lines (107 loc) · 3.95 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: PR Format
on:
pull_request:
types: [opened, reopened, edited]
permissions:
pull-requests: write
jobs:
check_title_format:
name: PR title must not contain "issue <number>"
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check PR title
run: |
TITLE=$(gh pr view "${{ github.event.number }}" --json title --template '{{.title}}')
echo "Title: $TITLE"
if echo "$TITLE" | grep -Eiq 'issue ?#?[0-9]+.+'; then
echo "❌ Title contains 'issue <number>' — not allowed."
exit 1
fi
echo "✅ Title format OK"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mandatory-checks-section-exists:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') && !(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: Mandatory Checks present
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check for existence of Mandatory Checks section
id: check_mandatory_section
run: |
set -e
BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}')
if echo "$BODY" | grep -q "### Mandatory checks"; then
echo "✅ '### Mandatory checks' section found."
else
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
checklist-checked:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') &&
!(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: PR checklist OK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check for PR checklist
id: check_changelog_modification
run: |
set -e
BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}' | grep -A5000 '### Mandatory checks')
echo "Found body: $BODY"
# Ensure the section exists
if ! printf '%s\n' "$BODY" | grep -q "### Mandatory checks"; then
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi
BOXES=$(printf '%s\n' "$BODY" | grep "^- \[")
echo "Found boxes: $BOXES"
while IFS= read -r line; do
if ! printf '%s\n' "$line" | grep -Eq "^- \[(x|/| )\] "; then
echo "❌ Found improperly formatted checkbox: '$line'"
exit 1
fi
done <<< "$BOXES"
LINE_COUNT=$(echo "$BOXES" | wc -l)
if [ "$LINE_COUNT" -ne 6 ]; then
echo "❌ Found $LINE_COUNT lines instead of 6 required lines"
exit 1
fi
echo "✅ All checkboxes are present and in the correct format."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}