Enhance the Practice Questions Page | Issue #499 #555
Workflow file for this run
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
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 | |
}); | |
} |