Skip to content

Commit

Permalink
Actions: attempt to validate PR description tests (#2810)
Browse files Browse the repository at this point in the history
GitHub includes the description comment when it formulates the commit
message, which we don't want as it's pretty messy. We will ask users to
remove the comment but we need to validate it before allowing merging.



Stolen from
https://github.com/orgs/community/discussions/84771#discussioncomment-8039595.
  • Loading branch information
phillco authored Feb 1, 2025
1 parent 1273b1c commit be42eb6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pr-description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Description

on:
pull_request:
types: [opened, edited, reopened]

jobs:
validate-pr-description:
runs-on: ubuntu-latest
steps:
- name: Set up workspace
uses: actions/checkout@v2

- name: Validate description
run: |
# Fetch PR description from env with jq
PR_DESCRIPTION=$(jq -r ".pull_request.body" "$GITHUB_EVENT_PATH")
KEYWORD="REQUIRED_KEYWORD"
# Ensure PR author removed the welcome comment
if [[ $PR_DESCRIPTION = *"<!--"* ]] || [[ $PR_DESCRIPTION = *"-->"* ]]; then
echo "FAILED: Please remove the welcome comment from your PR description."
exit 1
else
echo "OK: Welcome comment is removed your PR description."
fi
echo "PASS: All checks OK!"

0 comments on commit be42eb6

Please sign in to comment.