Skip to content

Commit d91a8a0

Browse files
authored
[all] feat(ci): check if linked issues are present (#190)
1 parent bac34ac commit d91a8a0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check linked issues
2+
3+
on:
4+
pull_request_target:
5+
branches: [main]
6+
types: [opened, edited, reopened, synchronize]
7+
8+
jobs:
9+
check-pr-issue:
10+
name: Check Pull Request is linked to an issue
11+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') }}
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
steps:
17+
- name: Check for linked issues
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
PR_NUMBER: ${{ github.event.pull_request.number }}
21+
REPO: ${{ github.repository }}
22+
run: |
23+
# Get PR details including linked issues
24+
LINKED_ISSUES=$(gh pr view $PR_NUMBER --repo $REPO --json closingIssuesReferences --jq '.closingIssuesReferences | length')
25+
26+
if [ "$LINKED_ISSUES" -eq 0 ]; then
27+
echo "::error::No linked issues found. Please link at least one issue to this Pull Request."
28+
echo "You can link an issue by using keywords like 'Fixes #123', 'Closes #123', or 'Resolves #123' in the PR description."
29+
exit 1
30+
else
31+
echo "✓ Found $LINKED_ISSUES linked issue(s)"
32+
fi

0 commit comments

Comments
 (0)