Skip to content

Commit

Permalink
Update auto-label-pr.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjaliavv51 authored Jul 31, 2024
1 parent 5860c73 commit 079c513
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions .github/workflows/auto-label-pr.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
name: Auto Label PR
name: Auto Label PRs

on:
pull_request:
types: [opened, reopened, synchronize]
types: [opened, edited]

jobs:
label_pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Label PR
- uses: actions/labeler@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml

- name: Add GSSOC label
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
const prBody = pr.body ? pr.body.toLowerCase() : '';
const prTitle = pr.title.toLowerCase();
const addLabel = async (label) => {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: [label]
});
};
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['gssoc']
})
if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) {
await addLabel('documentation');
- name: Add additional labels based on title
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const title = context.payload.pull_request.title.toLowerCase();
const labelsToAdd = [];
if (title.includes('documentation')) {
labelsToAdd.push('documentation');
}
if (prBody.includes('feature') || prBody.includes('enhancement') || prTitle.includes('add') || prTitle.includes('implement')) {
await addLabel('enhancement');
if (title.includes('feature')) {
labelsToAdd.push('feature');
}
if (prBody.includes('bug') || prBody.includes('fix') || prTitle.includes('fix') || prTitle.includes('resolve')) {
await addLabel('bug');
if (title.includes('bug')) {
labelsToAdd.push('bug');
}
if (prBody.includes('gssoc')) {
await addLabel('gssoc');
if (labelsToAdd.length > 0) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd
});
}

0 comments on commit 079c513

Please sign in to comment.