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