Skip to content

Commit c0cbbb6

Browse files
Merge branch 'main' into accountinfo
Signed-off-by: Mukund Jha <mukundiiitg@gmail.com>
2 parents b704bf6 + e925c36 commit c0cbbb6

37 files changed

Lines changed: 421 additions & 244 deletions

.github/scripts/bot-advanced-check.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,20 @@ get_intermediate_count() {
8989
already_commented() {
9090
local user=$1
9191
local marker="$COMMENT_MARKER_PREFIX @$user"
92-
9392
gh issue view "$ISSUE_NUMBER" --repo "$REPO" \
9493
--json comments \
95-
--jq --arg marker "$marker" '
96-
.comments[].body
97-
| select(contains($marker))
98-
' | grep -q .
94+
--jq '.comments[].body' | grep -Fq "$marker"
9995
}
10096

10197
#######################################
10298
# Helper: is user currently assigned?
10399
#######################################
100+
104101
is_assigned() {
105102
local user=$1
106-
107103
gh issue view "$ISSUE_NUMBER" --repo "$REPO" \
108104
--json assignees \
109-
--jq --arg user "$user" '
110-
.assignees[].login | select(. == $user)
111-
' | grep -q .
105+
--jq '.assignees[].login' | grep -Fxq "$user"
112106
}
113107

114108
#######################################
@@ -215,8 +209,20 @@ $COMMENT_MARKER_PREFIX @$user"
215209
fi
216210

217211
if is_assigned "$user"; then
218-
log "Unassigning @$user."
219-
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --remove-assignee "$user"
212+
log "Unassigning @$user ..."
213+
json_body="{\"assignees\": [\"$user\"]}"
214+
response=$(
215+
gh api \
216+
--method DELETE \
217+
"repos/$REPO/issues/$ISSUE_NUMBER/assignees" \
218+
--input <(echo "$json_body") \
219+
|| echo "error"
220+
)
221+
if [[ "$response" != "error" ]]; then
222+
log "Successfully unassigned @$user."
223+
else
224+
log "Failed to unassign @$user."
225+
fi
220226
else
221227
log "User @$user already unassigned. Skipping."
222228
fi
@@ -248,4 +254,4 @@ else
248254
while read -r user; do
249255
[[ -n "$user" ]] && check_user "$user"
250256
done <<< "$ASSIGNEES"
251-
fi
257+
fi

.github/scripts/bot-gfi-assign-on-comment.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,41 @@ async function isRepoCollaborator({ github, owner, repo, username }) {
146146
}
147147

148148
try {
149-
await github.rest.repos.checkCollaborator({
149+
const response = await github.rest.repos.getCollaboratorPermissionLevel({
150150
owner,
151151
repo,
152152
username,
153153
});
154-
return true; // 204 = collaborator
154+
155+
const permission = response?.data?.permission;
156+
157+
const isTeamMember =
158+
permission === 'admin' ||
159+
permission === 'write' ||
160+
permission === 'maintain' ||
161+
permission === 'read';
162+
163+
console.log('[gfi-assign] isRepoCollaborator:', {
164+
username,
165+
permission,
166+
isTeamMember,
167+
});
168+
169+
return isTeamMember;
155170
} catch (error) {
156-
if (error?.status === 404 || isPermissionFailure(error)) {
157-
if (isPermissionFailure(error)) {
158-
console.log(
159-
'[gfi-assign] isRepoCollaborator: insufficient permissions; treating as non-collaborator',
160-
{ owner, repo, username, status: error.status }
161-
);
162-
}
171+
if (isPermissionFailure(error) || error?.status === 404) {
172+
console.log(
173+
'[gfi-assign] isRepoCollaborator: no permission / not collaborator',
174+
{ username, status: error.status }
175+
);
163176
return false;
164177
}
165-
throw error; // unexpected error
178+
throw error;
166179
}
167-
168180
}
169181

170182

183+
171184
/// START OF SCRIPT ///
172185
module.exports = async ({ github, context }) => {
173186
try {
@@ -220,7 +233,7 @@ module.exports = async ({ github, context }) => {
220233
username,
221234
});
222235

223-
if (isTeamMember) {
236+
if (isTeamMember) {
224237
console.log('[gfi-assign] Skip reminder: commenter is collaborator');
225238
return;
226239
}
@@ -397,4 +410,4 @@ module.exports = async ({ github, context }) => {
397410
});
398411
throw error;
399412
}
400-
};
413+
};

.github/workflows/bot-assignment-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Harden the runner
15-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
15+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
1616
with:
1717
egress-policy: audit
1818

.github/workflows/bot-beginner-assign-on-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Harden runner
26-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
26+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
2727
with:
2828
egress-policy: audit
2929

.github/workflows/bot-coderabbit-plan-trigger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
3535
steps:
3636
- name: Harden the runner
37-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
37+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
3838
with:
3939
egress-policy: audit
4040

.github/workflows/bot-community-calls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Harden the runner
30-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 #2.14.0
30+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 #2.14.1
3131
with:
3232
egress-policy: audit
3333

.github/workflows/bot-gfi-assign-on-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Harden runner
26-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
26+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
2727
with:
2828
egress-policy: audit
2929

.github/workflows/bot-gfi-candidate-notification.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Harden the runner
24-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76
24+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9
2525
with:
2626
egress-policy: audit
2727

.github/workflows/bot-inactivity-unassign.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
2626

2727
- name: Harden the runner
28-
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2
28+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9
2929
with:
3030
egress-policy: audit
3131

.github/workflows/bot-intermediate-assignment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Harden the runner
29-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
29+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
3030
with:
3131
egress-policy: audit
3232

0 commit comments

Comments
 (0)