From e74ba39539ba6bd68eba7f23f0cb7d72f02653a1 Mon Sep 17 00:00:00 2001 From: MIGHTY1o1 Date: Tue, 8 Oct 2024 22:22:07 +0530 Subject: [PATCH] Add atuto labeler --- .github/workflows/labeler.yml | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/labeler.yml diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..0aeb4a30 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -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 + }); + }