📝[documentation Update]: assign workflow added #3
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
name: Auto Label PR | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
label_pr: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- 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 ? 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] | |
}); | |
}; | |
if (prBody.includes('documentation') || prTitle.includes('doc') || prBody.includes('readme')) { | |
await addLabel('documentation'); | |
} | |
if (prBody.includes('feature') || prBody.includes('enhancement') || prTitle.includes('add') || prTitle.includes('implement')) { | |
await addLabel('enhancement'); | |
} | |
if (prBody.includes('bug') || prBody.includes('fix') || prTitle.includes('fix') || prTitle.includes('resolve')) { | |
await addLabel('bug'); | |
} | |
if (prBody.includes('gssoc')) { | |
await addLabel('gssoc'); | |
} |