You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log(`User not found for label: ${label.name}`);
66
+
continue;
67
+
}
68
+
69
+
// 7. Check if the user is in the org
70
+
let isMember = false;
71
+
try {
72
+
await github.rest.orgs.checkMembershipForUser({
73
+
org: 'TykTechnologies',
74
+
username: userWhoAddedLabel
75
+
});
76
+
// If this call succeeds, they're a member
77
+
isMember = true;
78
+
console.log(`User '${userWhoAddedLabel}' is a member of the organization '${'TykTechnologies'}'.`);
79
+
} catch (error) {
80
+
// If 404, user is not a member. Anything else is an unexpected error.
81
+
if (error.status === 404) {
82
+
console.log(`User '${userWhoAddedLabel}' is NOT a member of the organization '${'TykTechnologies'}'.`);
83
+
}else {
84
+
console.error(`An error occurred while checking membership for user '${userWhoAddedLabel}':`, error);
85
+
throw error;
86
+
}
87
+
}
88
+
89
+
// 8. Comment only if user is in the org
90
+
if (isMember) {
91
+
console.log(`Creating comment for label '${label.name}' on PR #${pullRequestNumber} by user '${userWhoAddedLabel}'.`);
92
+
await github.rest.issues.createComment({
93
+
owner: context.repo.owner,
94
+
repo: context.repo.repo,
95
+
issue_number: pullRequestNumber,
96
+
body: `/release to ${label.name}`
97
+
});
98
+
}else{
99
+
console.log(`No comment created for label '${label.name}' on PR #${pullRequestNumber} because the user '${userWhoAddedLabel}' is not a member of the organization 'TykTechnologies'.`);
100
+
}
101
+
}else{
102
+
console.log(`Label '${label.name}' does not match the expected format.`);
0 commit comments