Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/scripts/filter-discussions-to-close.jq
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 1. It has a warning comment containing the unique marker
# 2. That warning comment was posted by the bot
# 3. That warning comment is older than WARNING_DAYS
# 4. The discussion hasn't been updated since the warning (or updates are also old)
# 4. There are no comments from non-bot users after the warning
#
# Input: GraphQL response with discussions data
# Arguments:
Expand Down Expand Up @@ -39,8 +39,20 @@
# Only proceed if the warning comment is old enough
| select($warningComment.createdAt <= $warningCutoff)

# Only proceed if the discussion hasn't been updated since the warning
| select($discussion.updatedAt < $warningComment.createdAt)
# Check if there are any comments from non-bot users after the warning
# Note: We can't rely on updatedAt because the bot's warning comment itself
# updates the discussion's updatedAt timestamp
| (
(.comments.nodes // [])
| map(
select(.createdAt > $warningComment.createdAt)
| select(.author.login != $botLogin)
)
| length
) as $nonBotCommentsAfterWarning

# Only proceed if there are no comments from non-bot users after the warning
| select($nonBotCommentsAfterWarning == 0)

# Output as JSON
| @json
7 changes: 5 additions & 2 deletions .github/scripts/process-stale-discussions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ echo ""
echo "Bot login: $BOT_LOGIN"

# Verify bot login is accessible
if ! BOT_INFO=$(gh api /users/$BOT_LOGIN 2>&1); then
echo "Warning: Could not verify bot user '$BOT_LOGIN'" >&2
# Note: The REST API uses the [bot] suffix for GitHub App bots, while the GraphQL API
# returns author.login without the suffix. We verify using the [bot] suffix.
BOT_LOGIN_FOR_REST="${BOT_LOGIN}[bot]"
if ! BOT_INFO=$(gh api "/users/$BOT_LOGIN_FOR_REST" 2>&1); then
echo "Warning: Could not verify bot user '$BOT_LOGIN_FOR_REST'" >&2
echo "The script will continue, but make sure BOT_LOGIN is correct." >&2
echo "API Response: $BOT_INFO" >&2
else
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/discussions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Fetch and process stale discussions
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
BOT_LOGIN: ${{ steps.generate_token.outputs.app-slug }}[bot]
BOT_LOGIN: ${{ steps.generate_token.outputs.app-slug }}
STALE_DAYS: ${{ env.STALE_DAYS }}
WARNING_DAYS: ${{ env.WARNING_DAYS }}
WARNING_MESSAGE: ${{ env.WARNING_MESSAGE }}
Expand Down