Skip to content

Commit

Permalink
Update add-gssoc-label-pr.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjaliavv51 authored Jul 29, 2024
1 parent a7b3d57 commit ac53994
Showing 1 changed file with 59 additions and 37 deletions.
96 changes: 59 additions & 37 deletions .github/workflows/add-gssoc-label-pr.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
name: Auto Label PRs
name: Auto Label PR

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

jobs:
label_prs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
const title = pr.title.toLowerCase();
const body = pr.body ? pr.body.toLowerCase() : '';
const labels = [];
if (title.includes('gssoc') || body.includes('gssoc')) {
labels.push('GSSoC');
}
if (title.includes('enhancement') || body.includes('enhancement')) {
labels.push('Enhancement');
}
if (title.includes('bug') || body.includes('bug')) {
labels.push('Bug');
}
if (title.includes('documentation') || body.includes('documentation')) {
labels.push('Documentation');
}
if (labels.length > 0) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
labels: labels
});
}
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler.yml

- name: Label GSSOC
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['GSSOC']
})
- name: Label documentation
if: contains(github.event.pull_request.title, 'docs') || contains(github.event.pull_request.body, 'documentation')
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['documentation']
})
- name: Label enhancement
if: contains(github.event.pull_request.title, 'feature') || contains(github.event.pull_request.body, 'enhancement')
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['enhancement']
})
- name: Label bug
if: contains(github.event.pull_request.title, 'fix') || contains(github.event.pull_request.body, 'bug')
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['bug']
})

0 comments on commit ac53994

Please sign in to comment.