File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed
Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 33# 1. It has a warning comment containing the unique marker
44# 2. That warning comment was posted by the bot
55# 3. That warning comment is older than WARNING_DAYS
6- # 4. The discussion hasn't been updated since the warning (or updates are also old)
6+ # 4. There are no comments from non-bot users after the warning
77#
88# Input: GraphQL response with discussions data
99# Arguments:
3939# Only proceed if the warning comment is old enough
4040| select ($warningComment .createdAt <= $warningCutoff )
4141
42- # Only proceed if the discussion hasn't been updated since the warning
43- | select ($discussion .updatedAt < $warningComment .createdAt )
42+ # Check if there are any comments from non-bot users after the warning
43+ # Note: We can't rely on updatedAt because the bot's warning comment itself
44+ # updates the discussion's updatedAt timestamp
45+ | (
46+ (.comments.nodes // [])
47+ | map (
48+ select (.createdAt > $warningComment .createdAt )
49+ | select (.author.login != $botLogin )
50+ )
51+ | length
52+ ) as $nonBotCommentsAfterWarning
53+
54+ # Only proceed if there are no comments from non-bot users after the warning
55+ | select ($nonBotCommentsAfterWarning == 0 )
4456
4557# Output as JSON
4658| @json
Original file line number Diff line number Diff line change @@ -131,8 +131,11 @@ echo ""
131131echo " Bot login: $BOT_LOGIN "
132132
133133# Verify bot login is accessible
134- if ! BOT_INFO=$( gh api /users/$BOT_LOGIN 2>&1 ) ; then
135- echo " Warning: Could not verify bot user '$BOT_LOGIN '" >&2
134+ # Note: The REST API uses the [bot] suffix for GitHub App bots, while the GraphQL API
135+ # returns author.login without the suffix. We verify using the [bot] suffix.
136+ BOT_LOGIN_FOR_REST=" ${BOT_LOGIN} [bot]"
137+ if ! BOT_INFO=$( gh api " /users/$BOT_LOGIN_FOR_REST " 2>&1 ) ; then
138+ echo " Warning: Could not verify bot user '$BOT_LOGIN_FOR_REST '" >&2
136139 echo " The script will continue, but make sure BOT_LOGIN is correct." >&2
137140 echo " API Response: $BOT_INFO " >&2
138141else
Original file line number Diff line number Diff line change 4242 - name : Fetch and process stale discussions
4343 env :
4444 GH_TOKEN : ${{ steps.generate_token.outputs.token }}
45- BOT_LOGIN : ${{ steps.generate_token.outputs.app-slug }}[bot]
45+ BOT_LOGIN : ${{ steps.generate_token.outputs.app-slug }}
4646 STALE_DAYS : ${{ env.STALE_DAYS }}
4747 WARNING_DAYS : ${{ env.WARNING_DAYS }}
4848 WARNING_MESSAGE : ${{ env.WARNING_MESSAGE }}
You can’t perform that action at this time.
0 commit comments