Skip to content

Commit 390eac8

Browse files
authored
Fixes to the community labeling GitHub Action (#3030)
* Debugging Signed-off-by: Przemek Tredak <ptredak@nvidia.com> * More debugging Signed-off-by: Przemek Tredak <ptredak@nvidia.com> * Distinguish the users based on the write permissions rather than relying on the member field, which could be set to private Signed-off-by: Przemek Tredak <ptredak@nvidia.com> * Fix Signed-off-by: Przemek Tredak <ptredak@nvidia.com> --------- Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
1 parent 82776bc commit 390eac8

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

.github/workflows/community_label.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,27 @@ jobs:
3333
const isOrgMember =
3434
association === "MEMBER" || association === "OWNER";
3535
36+
let permission = "none";
37+
38+
try {
39+
const res = await github.rest.repos.getCollaboratorPermissionLevel({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
username: user,
43+
});
44+
permission = res.data.permission;
45+
} catch (e) {
46+
if (e.status !== 404) throw e;
47+
}
48+
49+
const isCore = permission === "write" || permission === "admin";
3650
if (!isOrgMember) {
3751
targetLabel = communityLabel;
3852
} else {
39-
let permission = "none";
40-
41-
try {
42-
const res = await github.rest.repos.getCollaboratorPermissionLevel({
43-
owner: context.repo.owner,
44-
repo: context.repo.repo,
45-
username: user,
46-
});
47-
permission = res.data.permission;
48-
} catch (e) {
49-
if (e.status !== 404) throw e;
50-
}
51-
52-
const isCore = permission === "write" || permission === "admin";
53-
54-
if (!isCore) {
55-
targetLabel = orgLabel;
56-
}
53+
targetLabel = orgLabel;
5754
}
5855
59-
if (targetLabel) {
56+
if (!isCore) {
6057
await github.rest.issues.addLabels({
6158
owner: context.repo.owner,
6259
repo: context.repo.repo,

0 commit comments

Comments
 (0)