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 5d6fde6 commit 5f83ec0
Showing 1 changed file with 50 additions and 56 deletions.
106 changes: 50 additions & 56 deletions .github/workflows/add-gssoc-label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,58 @@ name: Auto Label PR

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

jobs:
label:
label_pr:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler.yml
- name: Checkout code
uses: actions/checkout@v3

- 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']
})
- name: Label PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
const prBody = pr.body.toLowerCase();
const prTitle = pr.title.toLowerCase();
// Add gssoc label to all PRs
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['gssoc']
});
// Check for documentation changes
if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['documentation']
});
}
// Check for enhancements
if (prBody.includes('feature') || prBody.includes('enhancement') || prTitle.includes('add') || prTitle.includes('implement')) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['enhancement']
});
}
// Check for bugs
if (prBody.includes('bug') || prBody.includes('fix') || prTitle.includes('fix') || prTitle.includes('resolve')) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['bug']
});
}

0 comments on commit 5f83ec0

Please sign in to comment.