fix: action-agent.sh fetches comments without bot filtering (#243)
Resolve the bot username dynamically from CODEBERG_TOKEN via the /user API endpoint and filter out bot comments from the prior-context section. Additional bot accounts can be specified via CODEBERG_BOT_USERNAMES env var (comma-separated). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
00d11efa82
commit
5157064bf0
2 changed files with 19 additions and 2 deletions
|
|
@ -18,6 +18,10 @@ CODEBERG_TOKEN=
|
||||||
# Branch protection: this account must be in the approvals whitelist.
|
# Branch protection: this account must be in the approvals whitelist.
|
||||||
REVIEW_BOT_TOKEN=
|
REVIEW_BOT_TOKEN=
|
||||||
|
|
||||||
|
# Comma-separated Codeberg usernames to filter from issue comments.
|
||||||
|
# The token owner is auto-detected; add extra bot accounts here if needed.
|
||||||
|
CODEBERG_BOT_USERNAMES=
|
||||||
|
|
||||||
# ── Woodpecker CI ─────────────────────────────────────────────────────────
|
# ── Woodpecker CI ─────────────────────────────────────────────────────────
|
||||||
WOODPECKER_TOKEN=
|
WOODPECKER_TOKEN=
|
||||||
WOODPECKER_SERVER=http://localhost:8000
|
WOODPECKER_SERVER=http://localhost:8000
|
||||||
|
|
|
||||||
|
|
@ -126,14 +126,27 @@ if [ -n "$YAML_MODEL" ]; then
|
||||||
log "model from front matter: ${YAML_MODEL}"
|
log "model from front matter: ${YAML_MODEL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Fetch existing comments (resume context) ---
|
# --- Resolve bot username(s) for comment filtering ---
|
||||||
|
_bot_login=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
|
"${CODEBERG_API%%/repos*}/user" | jq -r '.login // empty' 2>/dev/null || true)
|
||||||
|
|
||||||
|
# Build list: token owner + any extra names from CODEBERG_BOT_USERNAMES (comma-separated)
|
||||||
|
_bot_logins="${_bot_login}"
|
||||||
|
if [ -n "${CODEBERG_BOT_USERNAMES:-}" ]; then
|
||||||
|
_bot_logins="${_bot_logins:+${_bot_logins},}${CODEBERG_BOT_USERNAMES}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Fetch existing comments (resume context, excluding bot comments) ---
|
||||||
COMMENTS_JSON=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
COMMENTS_JSON=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
"${CODEBERG_API}/issues/${ISSUE}/comments?limit=50") || true
|
"${CODEBERG_API}/issues/${ISSUE}/comments?limit=50") || true
|
||||||
|
|
||||||
PRIOR_COMMENTS=""
|
PRIOR_COMMENTS=""
|
||||||
if [ -n "$COMMENTS_JSON" ] && [ "$COMMENTS_JSON" != "null" ] && [ "$COMMENTS_JSON" != "[]" ]; then
|
if [ -n "$COMMENTS_JSON" ] && [ "$COMMENTS_JSON" != "null" ] && [ "$COMMENTS_JSON" != "[]" ]; then
|
||||||
PRIOR_COMMENTS=$(printf '%s' "$COMMENTS_JSON" | \
|
PRIOR_COMMENTS=$(printf '%s' "$COMMENTS_JSON" | \
|
||||||
jq -r '.[] | "[\(.user.login) at \(.created_at[:19])]\n\(.body)\n---"' 2>/dev/null || true)
|
jq -r --arg bots "$_bot_logins" \
|
||||||
|
'($bots | split(",") | map(select(. != ""))) as $bl |
|
||||||
|
.[] | select(.user.login as $u | $bl | index($u) | not) |
|
||||||
|
"[\(.user.login) at \(.created_at[:19])]\n\(.body)\n---"' 2>/dev/null || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Create Matrix thread for this issue ---
|
# --- Create Matrix thread for this issue ---
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue