Skip to content

Commit be42eb6

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 be42eb6

File tree

1 file changed

+28
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)