-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1283 from smog-root/patch-1
Implement GitHub PR Issue Checker Workflow
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: PR Issue Checker | ||
# Created by @smog-root. | ||
on: | ||
pull_request: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
check_pr_details: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies (if needed) | ||
run: pip install re # Install Python's regex library (not needed if using built-in) | ||
|
||
- name: Check PR Description and Title | ||
id: check_pr_details | ||
run: | | ||
python -c " | ||
import re | ||
import sys | ||
import os | ||
|
||
pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '') | ||
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '') | ||
|
||
# Check if PR description is present | ||
if not pr_description: | ||
print('PR description is missing.') | ||
sys.exit(1) | ||
|
||
# Check if the PR description contains 'Fixes #<issue-number>' | ||
if not re.search(r'Fixes #[0-9]+', pr_description): | ||
print('The PR description should include Fixes #<issue-number>.') | ||
sys.exit(1) | ||
|
||
# Check if the PR title starts with FIX, FEAT, or DOC | ||
if not re.match(r'^(FIX|FEAT|DOC)', pr_title): | ||
print('The PR title should start with FIX, FEAT, or DOC.') | ||
sys.exit(1) | ||
|
||
print('PR description and title are valid.') | ||
" | ||
env: | ||
GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} | ||
GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }} | ||
- name: Output result | ||
run: echo "All checks passed." | ||
|