-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6baec1f
commit e74ba39
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Auto Labeler | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
pull_request: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
labeler: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Label issues and PRs | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const issue = context.payload.issue || context.payload.pull_request; | ||
const labels = []; | ||
// Define keywords and their associated labels | ||
const labelMappings = { | ||
'bug': 'bug', | ||
'enhancement': 'enhancement', | ||
'feature': 'feature', | ||
'good first issue': 'good first issue', | ||
'ui': 'ui', | ||
'hacktoberfest': 'hacktoberfest', | ||
'hacktoberfest-accepted': 'hacktoberfest-accepted', | ||
'documentation': 'documentation', | ||
'gssoc-ext': 'gssoc-ext', | ||
'workflow': 'workflow', | ||
'automation': 'automation', | ||
// Add more mappings as needed | ||
}; | ||
// Apply labels based on title or body content | ||
for (const [keyword, label] of Object.entries(labelMappings)) { | ||
if (issue.title.toLowerCase().includes(keyword) || issue.body.toLowerCase().includes(keyword)) { | ||
labels.push(label); | ||
} | ||
} | ||
if (labels.length > 0) { | ||
github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue.number, | ||
labels: labels | ||
}); | ||
} |