Skip to content

Commit 32cfcad

Browse files
naheel0jaseel0
andcommitted
add auto-label
Co-Authored-By: jaseel0 <225665919+jaseel0@users.noreply.github.com>
1 parent 1c1b2bf commit 32cfcad

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Challenge Submission
2+
description: Submit your solution for a weekly challenge.
3+
title: "[Week X] Challenge Submission - YOUR_USERNAME"
4+
labels: challenge, submission
5+
assignees: ''
6+
7+
---
8+
9+
## Challenge Information
10+
11+
- **Week:** [e.g., Week 1]
12+
- **Challenge Name:** [Name of the challenge]
13+
14+
## PR Link
15+
- Please link your Pull Request for this challenge: [PR link]
16+
17+
## Notes / Comments
18+
- Any comments about your submission, difficulties, or questions.

.github/workflows/auto-label.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Auto Label Issues & PRs"
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
labeler:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: "Add Labels Automatically"
15+
uses: actions/github-script@v7
16+
with:
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
script: |
19+
const issue = context.payload.issue || context.payload.pull_request;
20+
if (!issue) return;
21+
22+
const labelsToAdd = [];
23+
24+
// Auto-label PRs as challenge submissions if they include week-X in title
25+
if (issue.title.match(/week-\d+/i)) {
26+
labelsToAdd.push("challenge");
27+
}
28+
29+
// Auto-label issues that include "question"
30+
if (issue.title.toLowerCase().includes("question")) {
31+
labelsToAdd.push("question");
32+
}
33+
34+
// Auto-label issues that include "bug"
35+
if (issue.title.toLowerCase().includes("bug")) {
36+
labelsToAdd.push("bug");
37+
}
38+
39+
if (labelsToAdd.length > 0) {
40+
await github.rest.issues.addLabels({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
issue_number: issue.number,
44+
labels: labelsToAdd,
45+
});
46+
console.log("Labels added:", labelsToAdd.join(", "));
47+
} else {
48+
console.log("No labels added for this issue/PR.");
49+
}

0 commit comments

Comments
 (0)