|
| 1 | +# PR Issue Checker |
| 2 | + |
| 3 | +A GitHub Action that ensures pull requests have linked issues. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +Create `.github/workflows/pr-issue-check.yml`: |
| 8 | + |
| 9 | +```yaml |
| 10 | +name: PR Issue Check |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + types: [opened, edited, synchronize, labeled, unlabeled] |
| 15 | + |
| 16 | +permissions: |
| 17 | + pull-requests: write |
| 18 | + issues: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + check-linked-issue: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: plotly/pr-issue-checker |
| 25 | + with: |
| 26 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | +``` |
| 28 | +
|
| 29 | +Done! The action will now check all PRs for linked issues. |
| 30 | +
|
| 31 | +## What It Does |
| 32 | +
|
| 33 | +1. When a PR is opened → Checks if it links an issue |
| 34 | +2. No issue linked → Posts a comment asking for one |
| 35 | +3. Issue is linked → Updates comment with thanks |
| 36 | +4. Has exempt label → Bypasses the requirement |
| 37 | +
|
| 38 | +## Configuration |
| 39 | +
|
| 40 | +### Custom Messages |
| 41 | +
|
| 42 | +```yaml |
| 43 | +- uses: plotly/pr-issue-checker@v1 |
| 44 | + with: |
| 45 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + thank-you-message: 'Thanks for contributing! 🚀' |
| 47 | + request-issue-message: 'Please link an issue to this PR.' |
| 48 | + issue-added-message: 'Great! Issue linked! ✅' |
| 49 | +``` |
| 50 | +
|
| 51 | +### Exempt Labels |
| 52 | +
|
| 53 | +```yaml |
| 54 | +- uses: plotly/pr-issue-checker@v1 |
| 55 | + with: |
| 56 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + exempt-labels: 'dependencies,documentation,no-issue-needed' |
| 58 | +``` |
| 59 | +
|
| 60 | +### Using Outputs |
| 61 | +
|
| 62 | +```yaml |
| 63 | +- uses: plotly/pr-issue-checker@v1 |
| 64 | + id: check |
| 65 | + with: |
| 66 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | +- run: echo "Check passed: ${{ steps.check.outputs.check-passed }}" |
| 69 | +``` |
| 70 | +
|
| 71 | +## Inputs |
| 72 | +
|
| 73 | +| Input | Description | Default | |
| 74 | +|-------|-------------|---------| |
| 75 | +| `github-token` | GitHub token (required) | - | |
| 76 | +| `exempt-labels` | Labels that bypass the check | `no-issue-needed,dependencies` | |
| 77 | +| `comment-identifier` | Hidden HTML comment marker | `<!-- pr-issue-checker -->` | |
| 78 | +| `thank-you-message` | Thank you message | `Thank you for your contribution! 🎉` | |
| 79 | +| `request-issue-message` | Request message | `Could you please link an issue to this PR? This helps us track the context and purpose of changes.` | |
| 80 | +| `issue-added-message` | Success message | `Thanks for adding an issue! ✅` | |
| 81 | + |
| 82 | +## Outputs |
| 83 | + |
| 84 | +| Output | Description | |
| 85 | +|--------|-------------| |
| 86 | +| `has-linked-issue` | Whether PR has linked issue (`true`/`false`) | |
| 87 | +| `is-exempt` | Whether PR is exempt (`true`/`false`) | |
| 88 | +| `check-passed` | Whether check passed (`true`/`false`) | |
| 89 | + |
| 90 | +## How to Link Issues |
| 91 | + |
| 92 | +Contributors can link issues by adding to PR description: |
| 93 | +- `Fixes #123` |
| 94 | +- `Closes #456` |
| 95 | +- `Resolves #789` |
| 96 | +- `#123` (simple mention) |
| 97 | + |
| 98 | +Or using GitHub's UI to link related issues. |
| 99 | + |
| 100 | +## Development |
| 101 | + |
| 102 | +```bash |
| 103 | +# Install dependencies |
| 104 | +npm install |
| 105 | +
|
| 106 | +# Make changes to scripts/*.js |
| 107 | +
|
| 108 | +# Build |
| 109 | +npm run build |
| 110 | +``` |
| 111 | + |
| 112 | +**Important:** Always commit the `dist/` folder - it's required for the action to work. |
| 113 | + |
| 114 | +## License |
| 115 | + |
| 116 | +MIT |
0 commit comments