Skip to content

Commit

Permalink
Merge pull request #2569 from hathach/fix-labler-error
Browse files Browse the repository at this point in the history
try catch labeler rest api
  • Loading branch information
hathach authored Apr 3, 2024
2 parents 60acb99 + 252e630 commit b8d4684
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@ jobs:
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,
try {
// Check for Adafruit membership
const adafruitResponse = await github.rest.orgs.checkMembershipForUser({
org: 'adafruit',
username: username
});
if (collaboratorResponse.status === 204) {
console.log('Contributor');
label = 'Prio Higher';
if (adafruitResponse.status === 204) {
console.log('Adafruit Member');
label = 'Prio Urgent';
} else {
console.log('Not a contributor or Adafruit member');
// If not a Adafruit member, 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';
}
}
} catch (error) {
console.log(`Error processing user ${username}: ${error.message}`);
}
if (label !== '') {
Expand Down

0 comments on commit b8d4684

Please sign in to comment.