Skip to content

Commit c790dc8

Browse files
committed
Initial commit
0 parents  commit c790dc8

File tree

13 files changed

+33734
-0
lines changed

13 files changed

+33734
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow tests the action in this repository
2+
name: Test PR Issue Checker
3+
4+
on:
5+
pull_request:
6+
types: [opened, edited, synchronize, labeled, unlabeled]
7+
8+
permissions:
9+
pull-requests: write
10+
issues: read
11+
12+
jobs:
13+
test-action:
14+
runs-on: ubuntu-latest
15+
name: Test action in this repo
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Check PR has linked issue
21+
id: issue-check
22+
uses: ./ # Uses the action from this repository
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
exempt-labels: 'no-issue-needed,dependencies'
26+
thank-you-message: 'Thank you for your contribution! 🎉'
27+
request-issue-message: 'Could you please link an issue to this PR? This helps us track the context and purpose of changes.'
28+
issue-added-message: 'Thanks for adding an issue! ✅'
29+
30+
- name: Summary
31+
if: always()
32+
run: |
33+
echo "### PR Issue Check Results" >> $GITHUB_STEP_SUMMARY
34+
echo "" >> $GITHUB_STEP_SUMMARY
35+
echo "- Has linked issue: \`${{ steps.issue-check.outputs.has-linked-issue }}\`" >> $GITHUB_STEP_SUMMARY
36+
echo "- Is exempt: \`${{ steps.issue-check.outputs.is-exempt }}\`" >> $GITHUB_STEP_SUMMARY
37+
echo "- Check passed: \`${{ steps.issue-check.outputs.check-passed }}\`" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
*.log
3+
.DS_Store
4+
.env
5+
.vscode/
6+
.idea/

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Contributing
2+
3+
## Development
4+
5+
1. Install dependencies:
6+
```bash
7+
npm install
8+
```
9+
10+
2. Make your changes in `scripts/`
11+
12+
3. Build:
13+
```bash
14+
npm run build
15+
```
16+
17+
4. Test locally by creating a PR in this repo
18+
19+
5. Commit both `scripts/` and `dist/`:
20+
```bash
21+
git add scripts/ dist/
22+
git commit -m "Your changes"
23+
```
24+
25+
## Release Process
26+
27+
1. Build:
28+
```bash
29+
npm run build
30+
git add dist/
31+
git commit -m "Build for release"
32+
```
33+
34+
2. Tag and push:
35+
```bash
36+
git tag -a v1.0.1 -m "Release v1.0.1: Description"
37+
git push origin v1.0.1
38+
39+
# Update major version tag
40+
git tag -f v1 -m "Release v1"
41+
git push -f origin v1
42+
```
43+
44+
3. Create GitHub Release (optional)
45+
46+
## Versioning
47+
48+
- **Major (v2.0.0)**: Breaking changes
49+
- **Minor (v1.1.0)**: New features, backward compatible
50+
- **Patch (v1.0.1)**: Bug fixes
51+
52+
## Important
53+
54+
- Always run `npm run build` before committing
55+
- The `dist/` folder must be committed
56+
- Use modern JavaScript (Node 20+)
57+
- Add comments for complex logic

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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

action.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'PR Issue Checker'
2+
description: 'Checks if a PR has a linked issue and posts/updates comments accordingly'
3+
author: 'Plotly'
4+
5+
branding:
6+
icon: 'check-circle'
7+
color: 'green'
8+
9+
inputs:
10+
github-token:
11+
description: 'GitHub token for API access'
12+
required: true
13+
exempt-labels:
14+
description: 'Comma-separated list of labels that exempt PRs from requiring an issue'
15+
required: false
16+
default: 'no-issue-needed,dependencies'
17+
comment-identifier:
18+
description: 'Unique identifier for the bot comment (hidden marker)'
19+
required: false
20+
default: '<!-- pr-issue-checker -->'
21+
thank-you-message:
22+
description: 'Message to thank contributors'
23+
required: false
24+
default: 'Thank you for your contribution! 🎉'
25+
request-issue-message:
26+
description: 'Message to request an issue be linked'
27+
required: false
28+
default: 'Could you please link an issue to this PR? This helps us track the context and purpose of changes.'
29+
issue-added-message:
30+
description: 'Message when issue is added'
31+
required: false
32+
default: 'Thanks for adding an issue! ✅'
33+
34+
outputs:
35+
has-linked-issue:
36+
description: 'Whether the PR has a linked issue (true/false)'
37+
value: ${{ steps.check-issue.outputs.has-linked-issue }}
38+
is-exempt:
39+
description: 'Whether the PR is exempt from requiring an issue (true/false)'
40+
value: ${{ steps.check-issue.outputs.is-exempt }}
41+
check-passed:
42+
description: 'Whether the check passed (has issue or is exempt)'
43+
value: ${{ steps.check-issue.outputs.check-passed }}
44+
45+
runs:
46+
using: 'node20'
47+
main: 'dist/index.js'

0 commit comments

Comments
 (0)