-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from samyak-aditya/main
Fixed #26 : Updated the "auto-label" workflow
- Loading branch information
Showing
1 changed file
with
31 additions
and
18 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,26 +1,39 @@ | ||
name: Auto Label PRs and Issues | ||
name: Auto Label Issue | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
issues: | ||
types: [opened] | ||
types: [opened, reopened, edited] | ||
|
||
jobs: | ||
auto-label: | ||
label_issue: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
issues: write | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Auto-label PRs and Issues | ||
uses: actions_ecosystem/action-add-labels@v1 # Correct action | ||
- name: Label Issue | ||
uses: actions/github-script@v6 | ||
with: | ||
labels: | | ||
gssoc-ext | ||
hacktoberfest-accepted | ||
level1 | ||
github_token: ${{ secrets.GITHUB_TOKEN }} # Correct key | ||
repo: ${{ github.repository }} # Specifies the repository | ||
number: ${{ github.event.issue.number || github.event.pull_request.number }} # Selects the issue or PR number dynamically | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const issue = context.payload.issue; | ||
const issueBody = issue.body ? issue.body.toLowerCase() : ''; | ||
const issueTitle = issue.title.toLowerCase(); | ||
// Add gssoc label to all issues | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue.number, | ||
labels: ['gssoc-ext','hacktoberfest-accepted'] | ||
}); | ||
const addLabel = async (label) => { | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue.number, | ||
labels: [label] | ||
}); | ||
}; | ||
if (issueBody.includes('documentation') || issueTitle.includes('doc') || issueBody.includes('readme')) { | ||
await addLabel('level1'); | ||
} |