Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize GitHub Actions to aid checking of commit message #2429

Merged
merged 15 commits into from
Feb 24, 2024
39 changes: 39 additions & 0 deletions .github/workflows/pr-message-reminder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR Message Reminder
on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
types:
- opened
- synchronize
- reopened
- edited

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
remind-pr-author:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Extract Proposed Commit Message
run: |
python scripts/process_message.py "${TEXT_BODY}" > processed_body.txt
processed_body=$(cat processed_body.txt)
proposed_commit_message=$(echo "$processed_body" | awk '/\\*\\*Proposed commit message: \\\(wrap lines at 72 characters\\\)\\*\\*/,/\\*\\*Checklist:\\*\\*/' | tail -n +2 | head -n -3)
echo "Proposed commit message:"
echo "$proposed_commit_message"
if ! grep -q '[^[:space:]]' <<< "$proposed_commit_message"; then
echo "Please fill in the proposed commit message section in the pull request description."
exit 1
fi
env:
TEXT_BODY: ${{ github.event.pull_request.body }}

15 changes: 15 additions & 0 deletions scripts/process_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import json
import re
import sys

markdown_content = sys.argv[1]

# Preprocessing the markdown content
markdown_content = markdown_content.replace('`', '\\`')
markdown_content = markdown_content.replace('(', '\\(').replace(')', '\\)')
markdown_content = re.sub(r'<!--.*?-->', '', markdown_content, flags=re.DOTALL) # Remove HTML comments

print(markdown_content)



Loading