-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5860c73
commit 079c513
Showing
1 changed file
with
36 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
} |