Skip to content

Commit 2d9f784

Browse files
authored
Actions: attempt to validate PR description tests (#2810)
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.
1 parent 1273b1c commit 2d9f784

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/pr-description.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PR Description
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
merge_group:
7+
branches: [main]
8+
9+
jobs:
10+
validate-pr-description:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Set up workspace
14+
uses: actions/checkout@v2
15+
16+
- name: Validate description
17+
run: |
18+
# Fetch PR description from env with jq
19+
PR_DESCRIPTION=$(jq -r ".pull_request.body" "$GITHUB_EVENT_PATH")
20+
KEYWORD="REQUIRED_KEYWORD"
21+
22+
# Ensure PR author removed the welcome comment
23+
if [[ $PR_DESCRIPTION = *"<!--"* ]] || [[ $PR_DESCRIPTION = *"-->"* ]]; then
24+
echo "FAILED: Please remove the welcome comment from your PR description."
25+
exit 1
26+
else
27+
echo "OK: Welcome comment is removed your PR description."
28+
fi
29+
30+
echo "PASS: All checks OK!"

0 commit comments

Comments
 (0)