Skip to content

Commit

Permalink
ci: fix regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
danctorres committed Dec 11, 2024
1 parent a26a709 commit 9e0d1ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/check_pr_description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ jobs:
PR_BODY=$(curl -s https://api.github.com/repos/${{
github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r .body)
echo "$PR_BODY"
pattern="https://github\.com/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/issues/([0-9]+)"
if [[ ! "$PR_BODY" =~ $pattern ]]; then
echo "Error: PR description must include an issue link in the format 'Issue: # 123' or 'Issue: https://github.com/owner/repo/issues/123'." >&2
pattern_1="https://github\.com/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/issues/([0-9]+)"
pattern_2="#[a-zA-Z0-9_-]+)"
if [[ ! "$PR_BODY" =~ $pattern_1 ]] && [[ ! "$PR_BODY" =~ $pattern_2 ]]; then
echo "Error: PR description must include an issue link in the format 'Issue: #123' or 'Issue: https://github.com/owner/repo/issues/123'." >&2
exit 1
else
echo "PR description contains a valid issue link."
fi
- name: Fail PR if no issue link found
if: failure()
run: |-
echo "Please add an issue link in the format 'Issue: # 123' or 'Issue: https://github.com/owner/repo/issues/123' in the PR description."
echo "Please add an issue link in the format 'Issue: #123' or 'Issue: https://github.com/owner/repo/issues/123' in the PR description."

0 comments on commit 9e0d1ab

Please sign in to comment.