Skip to content

Commit dd8129a

Browse files
authored
Implement PR Issue Checker Workflow
1 parent de1d817 commit dd8129a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/pr-checker.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: PR Issue Checker
2+
# Created by @smog-root.
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
7+
jobs:
8+
check_pr_details:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Install dependencies (if needed)
21+
run: pip install re # Install Python's regex library (not needed if using built-in)
22+
23+
- name: Check PR Description and Title
24+
id: check_pr_details
25+
run: |
26+
python -c "
27+
import re
28+
import sys
29+
import os
30+
31+
pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '')
32+
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '')
33+
34+
# Check if PR description is present
35+
if not pr_description:
36+
print('PR description is missing.')
37+
sys.exit(1)
38+
39+
# Check if the PR description contains 'Fixes #<issue-number>'
40+
if not re.search(r'Fixes #[0-9]+', pr_description):
41+
print('The PR description should include Fixes #<issue-number>.')
42+
sys.exit(1)
43+
44+
# Check if the PR title starts with FIX, FEAT, or DOC
45+
if not re.match(r'^(FIX|FEAT|DOC)', pr_title):
46+
print('The PR title should start with FIX, FEAT, or DOC.')
47+
sys.exit(1)
48+
49+
print('PR description and title are valid.')
50+
"
51+
env:
52+
GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
53+
GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
54+
55+
- name: Output result
56+
run: echo "All checks passed."
57+

0 commit comments

Comments
 (0)