Skip to content

Commit 471f3aa

Browse files
committed
update bot
1 parent a2324d5 commit 471f3aa

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

keyring.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ async function autoEvaluateDeveloper (token, owner, repo, issueNumber, username)
162162
const report = generateReport(stats, evaluation)
163163

164164
// 所有提交自动通过,只附加rank信息
165+
console.log('Creating approval comment with rank info...')
165166
await createComment(
166167
token,
167168
owner,
@@ -177,11 +178,14 @@ async function autoEvaluateDeveloper (token, owner, repo, issueNumber, username)
177178
'- 📝 Make sure your public key is properly formatted between `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----` markers\n\n' +
178179
'Your certificate will be issued automatically. Please wait a moment...'
179180
)
181+
console.log('Adding approved label...')
180182
await addLabel(token, owner, repo, issueNumber, 'approved')
181183
console.log(`Auto-approved: ${username} (Rank: ${evaluation.rank.level})`)
182184
} catch (error) {
183185
console.error('Error in auto-evaluation:', error)
186+
console.error('Error stack:', error.stack)
184187
// 如果评估失败,仍然自动通过但不显示rank信息
188+
console.log('Creating fallback approval comment...')
185189
await createComment(
186190
token,
187191
owner,
@@ -200,6 +204,7 @@ async function autoEvaluateDeveloper (token, owner, repo, issueNumber, username)
200204
'- 📝 Make sure your public key is properly formatted\n\n' +
201205
'Your certificate will be issued automatically. Please wait a moment...'
202206
)
207+
console.log('Adding approved label (fallback)...')
203208
await addLabel(token, owner, repo, issueNumber, 'approved')
204209
console.log(`Auto-approved (no rank): ${username}`)
205210
}
@@ -241,19 +246,25 @@ async function handleKeyringIssue () {
241246

242247
// Handle labeled event (approval)
243248
if (action !== 'labeled') {
244-
console.log('Not a labeled or opened event')
249+
console.log('Not a labeled or opened event, action:', action)
245250
return
246251
}
247252

253+
console.log('Handling labeled event')
248254
const label = context.payload.label
255+
console.log('Label:', label ? label.name : 'null')
256+
249257
if (!label || label.name !== 'approved') {
250-
console.log('Not an approved label')
258+
console.log('Not an approved label, skipping certificate issuance')
251259
return
252260
}
253261

262+
console.log('Approved label detected, proceeding with certificate issuance')
254263
const approver = context.payload.sender
264+
console.log('Approver:', approver.login)
255265

256266
const publicKeyPem = extractPublicKeyFromIssue(issueBody)
267+
console.log('Public key extracted:', publicKeyPem ? 'Yes' : 'No')
257268

258269
if (!publicKeyPem) {
259270
await createComment(

rank.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ async function fetchUserStats (username, token) {
143143
`
144144

145145
const { data } = await octokit.graphql(query, { login: username })
146+
147+
// Debug: 输出完整的GraphQL响应
148+
console.log('GraphQL Response:', JSON.stringify(data, null, 2))
149+
150+
if (!data || !data.user) {
151+
console.error('GraphQL data.user is null or undefined')
152+
console.error('Full response:', JSON.stringify(data, null, 2))
153+
throw new Error(`User not found or insufficient permissions to access user data`)
154+
}
155+
146156
const userData = data.user
147157

148158
// 计算总星标数

0 commit comments

Comments
 (0)