-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub Actions: add check for empty commit message
There is no checking of proposed commit message presence. PR authors may forget to include proposed commit message. Adding a check using GitHub Actions will help remind and ensure that authors don't miss out on filling in the commit message. Let's add a job to the a new workflow, pr-message-reminder.yml file to help automate checking and reminding of filling in the proposed commit message for each PR. This approach automates the process, without having to have other users check and remind PR authors themselves. Adding the new job to a new workflow will allow greater control of job triggers while maintaining clean code.
- Loading branch information
Showing
2 changed files
with
54 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,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 }} | ||
|
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,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) | ||
|
||
|
||
|