A GitHub Action that ensures pull requests have linked issues.
Create .github/workflows/pr-issue-check.yml:
name: PR Issue Check
on:
pull_request:
types: [opened, edited, synchronize, labeled, unlabeled]
permissions:
pull-requests: write
issues: read
jobs:
check-linked-issue:
runs-on: ubuntu-latest
steps:
- uses: plotly/pr-issue-checker
with:
github-token: ${{ secrets.GITHUB_TOKEN }}Done! The action will now check all PRs for linked issues.
- When a PR is opened → Checks if it links an issue
- No issue linked → Posts a comment asking for one
- Issue is linked → Updates comment with thanks
- Has exempt label → Bypasses the requirement
- uses: plotly/pr-issue-checker@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
thank-you-message: 'Thanks for contributing! 🚀'
request-issue-message: 'Please link an issue to this PR.'
issue-added-message: 'Great! Issue linked! ✅'- uses: plotly/pr-issue-checker@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
exempt-labels: 'dependencies,documentation,no-issue-needed'- uses: plotly/pr-issue-checker@v1
id: check
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: echo "Check passed: ${{ steps.check.outputs.check-passed }}"| Input | Description | Default |
|---|---|---|
github-token |
GitHub token (required) | - |
exempt-labels |
Labels that bypass the check | no-issue-needed,dependencies |
comment-identifier |
Hidden HTML comment marker | <!-- pr-issue-checker --> |
thank-you-message |
Thank you message | Thank you for your contribution! 🎉 |
request-issue-message |
Request message | Could you please link an issue to this PR? This helps us track the context and purpose of changes. |
issue-added-message |
Success message | Thanks for adding an issue! ✅ |
| Output | Description |
|---|---|
has-linked-issue |
Whether PR has linked issue (true/false) |
is-exempt |
Whether PR is exempt (true/false) |
check-passed |
Whether check passed (true/false) |
Contributors can link issues by adding to PR description:
Fixes #123Closes #456Resolves #789#123(simple mention)
Or using GitHub's UI to link related issues.
# Install dependencies
npm install
# Make changes to scripts/*.js
# Build
npm run buildImportant: Always commit the dist/ folder - it's required for the action to work.
MIT