mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 10:20:57 +00:00
Merge pull request #2540 from hathach/add-auto-label
add new labeler workflow
This commit is contained in:
commit
c028cfa7cf
63
.github/workflows/labeler.yml
vendored
Normal file
63
.github/workflows/labeler.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
name: Labeler
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
label-priority:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Label New Issue or PR
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.API_TOKEN_GITHUB }}
|
||||
script: |
|
||||
let label = '';
|
||||
let username = '';
|
||||
let issueOrPrNumber = 0;
|
||||
|
||||
if (context.eventName === 'issues') {
|
||||
username = context.payload.issue.user.login;
|
||||
issueOrPrNumber = context.payload.issue.number;
|
||||
} else if (context.eventName === 'pull_request') {
|
||||
username = context.payload.pull_request.user.login;
|
||||
issueOrPrNumber = context.payload.pull_request.number;
|
||||
}
|
||||
|
||||
// Check for Adafruit membership
|
||||
const adafruitResponse = await github.rest.orgs.checkMembershipForUser({
|
||||
org: 'adafruit',
|
||||
username: username
|
||||
});
|
||||
|
||||
if (adafruitResponse.status === 204) {
|
||||
console.log('Adafruit Member');
|
||||
label = 'Prio Urgent';
|
||||
} else {
|
||||
// Check if the user is a contributor
|
||||
const collaboratorResponse = await github.rest.repos.checkCollaborator({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
username: username
|
||||
});
|
||||
|
||||
if (collaboratorResponse.status === 204) {
|
||||
console.log('Contributor');
|
||||
label = 'Prio Higher';
|
||||
} else {
|
||||
console.log('Not a contributor or Adafruit member');
|
||||
}
|
||||
}
|
||||
|
||||
if (label !== '') {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueOrPrNumber,
|
||||
labels: [label]
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user