Skip to content

Commit

Permalink
[Chore] Adds untriaged only to issues not opened by collaborators (#6193
Browse files Browse the repository at this point in the history
)

* add label based on code owner

Signed-off-by: Ashwin P Chandran <[email protected]>

* test again

Signed-off-by: Ashwin P Chandran <[email protected]>

* removes log statements

Signed-off-by: Ashwin P Chandran <[email protected]>

---------

Signed-off-by: Ashwin P Chandran <[email protected]>
  • Loading branch information
ashwin-pc authored Apr 4, 2024
1 parent 557fbcf commit b92387a
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/add-untriaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,37 @@ on:
types: [opened, reopened, transferred]

jobs:
apply-label:
apply-label-if-not-collaborator:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- name: Check if issue author is a collaborator
id: check-collaborator
uses: actions/github-script@v6
with:
script: |
const issueAuthor = context.payload.issue.user.login;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
let isCollaborator = false;
try {
// Attempt to fetch user's permission level
await github.rest.repos.getCollaboratorPermissionLevel({
owner: repoOwner,
repo: repoName,
username: issueAuthor,
});
// If no error is thrown, the user is a collaborator
isCollaborator = true;
} catch (error) {
// Error thrown indicates the user is not a collaborator,
// or does not have explicit permission set.
console.log(`${issueAuthor} is not a collaborator.`);
}
core.setOutput('is_collaborator', isCollaborator.toString());
- name: Apply label if not a collaborator
if: steps.check-collaborator.outputs.is_collaborator == 'false'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
Expand Down

0 comments on commit b92387a

Please sign in to comment.