Skip to content

Commit ff3499f

Browse files
Merge pull request #107 from sshivanshg/chore/contributor-welcome-and-auto-labels
chore: welcome new contributors and auto-label issues/PRs
2 parents fc5779e + be8bef2 commit ff3499f

7 files changed

Lines changed: 231 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Bug report
3+
description: Something isn't working
4+
title: "[Bug] "
5+
labels: bug, contributor-friendly
6+
---
7+
8+
**Describe the bug**
9+
A clear description of what’s wrong.
10+
11+
**To reproduce**
12+
Steps to reproduce:
13+
1.
14+
2.
15+
16+
**Expected behavior**
17+
What you expected.
18+
19+
**Environment**
20+
- Browser / OS (if relevant)

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
blank_issues_enabled: true
2+
contact_links: []
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Feature request
3+
description: Suggest an improvement or new feature
4+
title: "[Enhancement] "
5+
labels: enhancement, contributor-friendly
6+
---
7+
8+
**Describe the feature**
9+
What you’d like to see.
10+
11+
**Why it’s useful**
12+
Brief use case or problem it solves.
13+
14+
**Optional: possible implementation**
15+
Rough idea of how it could work.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Auto-label issues (bug, enhancement, good first issue, maintainer vs contributor)
2+
name: Auto-label issues
3+
4+
on:
5+
issues:
6+
types: [opened, edited]
7+
8+
permissions:
9+
issues: write
10+
11+
jobs:
12+
label:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Label issue
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
const issue = context.payload.issue;
20+
const title = (issue.title || '').toLowerCase();
21+
const body = (issue.body || '').toLowerCase();
22+
const text = title + ' ' + body;
23+
24+
const labelsToAdd = [];
25+
26+
if (/\b(bug|fix|broken|error|fixes)\b/.test(text)) {
27+
labelsToAdd.push('bug');
28+
}
29+
if (/\b(feature|enhancement|improvement)\b/.test(text)) {
30+
labelsToAdd.push('enhancement');
31+
}
32+
if (/\b(doc|readme|documentation)\b/.test(text)) {
33+
labelsToAdd.push('documentation');
34+
}
35+
if (/\b(good first issue|first issue|starter)\b/.test(text)) {
36+
labelsToAdd.push('good first issue');
37+
}
38+
39+
if (/\[maintainer\]|maintainer only|internal\b/.test(text)) {
40+
labelsToAdd.push('maintainer-only');
41+
} else {
42+
labelsToAdd.push('contributor-friendly');
43+
}
44+
45+
const existing = (issue.labels || []).map(l => l.name);
46+
const toAdd = labelsToAdd.filter(l => !existing.includes(l));
47+
if (toAdd.length === 0) return;
48+
49+
await github.rest.issues.addLabels({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
issue_number: issue.number,
53+
labels: toAdd
54+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Auto-label PRs when opened/edited (bug, enhancement, documentation, etc.)
2+
name: Auto-label PRs
3+
4+
on:
5+
pull_request:
6+
types: [opened, edited]
7+
8+
permissions:
9+
pull-requests: write
10+
contents: read
11+
12+
jobs:
13+
label:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Label PR
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const pr = context.payload.pull_request;
21+
const title = (pr.title || '').toLowerCase();
22+
const body = (pr.body || '').toLowerCase();
23+
const text = title + ' ' + body;
24+
25+
const labelsToAdd = [];
26+
27+
if (/\b(bug|fix|fixes|broken)\b/.test(text)) {
28+
labelsToAdd.push('bug');
29+
}
30+
if (/\b(feature|enhancement|improvement)\b/.test(text)) {
31+
labelsToAdd.push('enhancement');
32+
}
33+
if (/\b(doc|readme|documentation)\b/.test(text)) {
34+
labelsToAdd.push('documentation');
35+
}
36+
37+
const existing = (pr.labels || []).map(l => l.name);
38+
const toAdd = labelsToAdd.filter(l => !existing.includes(l));
39+
if (toAdd.length === 0) return;
40+
41+
await github.rest.issues.addLabels({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
issue_number: pr.number,
45+
labels: toAdd
46+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Welcome new contributors (per project doc: "Pull requests are welcome. Found a bug? Open an issue.")
2+
name: Welcome new contributors
3+
4+
on:
5+
issues:
6+
types: [opened]
7+
pull_request:
8+
types: [opened]
9+
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
14+
jobs:
15+
welcome:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Welcome on first issue
19+
if: github.event_name == 'issues'
20+
uses: actions/github-script@v7
21+
with:
22+
script: |
23+
const author = context.payload.issue.user.login;
24+
const repo = context.repo;
25+
const { data: issueData } = await github.rest.search.issuesAndPullRequests({
26+
q: `repo:${repo.owner}/${repo.repo} is:issue author:${author}`
27+
});
28+
const isFirstIssue = issueData.total_count <= 1;
29+
const welcome = isFirstIssue
30+
? 'Welcome to the project! '
31+
: '';
32+
const body = welcome + 'Thanks for opening this issue. Pull requests are welcome—see [CONTRIBUTING](https://github.com/' + repo.owner + '/' + repo.repo + '/blob/main/CONTRIBUTING.md) for guidelines. Found a bug? Describe steps to reproduce and we\'ll label it.';
33+
await github.rest.issues.createComment({
34+
owner: repo.owner,
35+
repo: repo.repo,
36+
issue_number: context.payload.issue.number,
37+
body
38+
});
39+
40+
- name: Welcome on first PR
41+
if: github.event_name == 'pull_request'
42+
uses: actions/github-script@v7
43+
with:
44+
script: |
45+
const author = context.payload.pull_request.user.login;
46+
const repo = context.repo;
47+
const { data: prData } = await github.rest.search.issuesAndPullRequests({
48+
q: `repo:${repo.owner}/${repo.repo} is:pr author:${author}`
49+
});
50+
const isFirstPR = prData.total_count <= 1;
51+
const welcome = isFirstPR
52+
? 'Welcome to the project! '
53+
: '';
54+
const body = welcome + 'Thanks for your pull request. See [CONTRIBUTING](https://github.com/' + repo.owner + '/' + repo.repo + '/blob/main/CONTRIBUTING.md) for guidelines. We\'ll review as soon as we can.';
55+
await github.rest.issues.createComment({
56+
owner: repo.owner,
57+
repo: repo.repo,
58+
issue_number: context.payload.pull_request.number,
59+
body
60+
});

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing to Eye Lab
2+
3+
Thanks for your interest in contributing. Pull requests are welcome, and if you find a bug, please open an issue.
4+
5+
## Getting started
6+
7+
1. **Fork and clone** this repo.
8+
2. **Install dependencies** (see [README](README.md#-local-setup)):
9+
```bash
10+
npm install
11+
npm run serve
12+
```
13+
3. **Open an issue** before larger changes so we can align on approach.
14+
4. **Branch** from `main` and keep changes focused (e.g. one fix or feature per PR).
15+
16+
## What to work on
17+
18+
- **Good first issue** – Labeled issues that are suited for new contributors.
19+
- **Bug** – Something broken; please describe steps to reproduce.
20+
- **Enhancement** – New feature or improvement; describe the use case.
21+
22+
Maintainer-only or internal tasks are labeled separately; everything else is open for contributors.
23+
24+
## Pull requests
25+
26+
- Target the `main` branch.
27+
- Keep the PR small and the description clear.
28+
- Ensure `npm run build` passes locally.
29+
30+
We’ll review as soon as we can. Thanks for contributing.
31+
32+
---
33+
34+
**Note for maintainers:** The repo uses auto-labeling. Ensure these labels exist: `bug`, `enhancement`, `documentation`, `good first issue`, `maintainer-only`, `contributor-friendly`.

0 commit comments

Comments
 (0)