Merge pull request #2569 from hathach/fix-labler-error

try catch labeler rest api
This commit is contained in:
Ha Thach 2024-04-03 13:09:24 +07:00 committed by GitHub
commit b8d4684683
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,29 +28,31 @@ jobs:
issueOrPrNumber = context.payload.pull_request.number; issueOrPrNumber = context.payload.pull_request.number;
} }
// Check for Adafruit membership try {
const adafruitResponse = await github.rest.orgs.checkMembershipForUser({ // Check for Adafruit membership
org: 'adafruit', const adafruitResponse = await github.rest.orgs.checkMembershipForUser({
username: username org: 'adafruit',
});
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 username: username
}); });
if (collaboratorResponse.status === 204) { if (adafruitResponse.status === 204) {
console.log('Contributor'); console.log('Adafruit Member');
label = 'Prio Higher'; label = 'Prio Urgent';
} else { } 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 !== '') { if (label !== '') {