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 5f83ec0 commit e47ec97
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions .github/workflows/add-gssoc-label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ on:
jobs:
label_pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3

- 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 prBody = pr.body ? pr.body.toLowerCase() : '';
const prTitle = pr.title.toLowerCase();
// Add gssoc label to all PRs
Expand All @@ -28,32 +27,26 @@ jobs:
labels: ['gssoc']
});
// Check for documentation changes
if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) {
const addLabel = async (label) => {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['documentation']
labels: [label]
});
};
// Check for documentation changes
if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) {
await addLabel('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']
});
await addLabel('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']
});
await addLabel('bug');
}

0 comments on commit e47ec97

Please sign in to comment.