






























@@ -18,8 +18,8 @@ permissions:
1818contents: read
19192020concurrency:
21-group: clawsweeper-dispatch-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
22-cancel-in-progress: ${{ github.event.action == 'edited' || github.event.action == 'synchronize' || github.event.action == 'ready_for_review' }}
21+group: ${{ github.event_name == 'push' && format('clawsweeper-dispatch-{0}-{1}', github.repository, github.ref) || format('clawsweeper-dispatch-{0}-{1}', github.repository, github.event.issue.number || github.event.pull_request.number || github.run_id) }}
22+cancel-in-progress: ${{ github.event_name == 'push' || github.event.action == 'edited' || github.event.action == 'synchronize' || github.event.action == 'ready_for_review' }}
23232424jobs:
2525dispatch:
@@ -41,6 +41,34 @@ jobs:
4141if: ${{ github.event.action == 'labeled' || github.event.action == 'unlabeled' }}
4242run: sleep 20
434344+ - name: Debounce main push dispatch
45+if: ${{ github.event_name == 'push' }}
46+run: sleep 45
47+48+ - name: Install GitHub API backoff helper
49+run: |
50+ cat > "$RUNNER_TEMP/github-api-backoff.sh" <<'BASH'
51+ gh_api_with_retry() {
52+ local attempt output status lower_output
53+ for attempt in 1 2 3 4 5; do
54+ if output="$(gh api "$@" 2>&1)"; then
55+ printf '%s\n' "$output"
56+ return 0
57+ fi
58+ status=$?
59+ lower_output="${output,,}"
60+ if [[ "$lower_output" != *"rate limit"* && "$output" != *"HTTP 429"* ]]; then
61+ printf '%s\n' "$output" >&2
62+ return "$status"
63+ fi
64+ echo "::warning::GitHub API throttled ClawSweeper dispatch on attempt ${attempt}; retrying after backoff." >&2
65+ sleep $((attempt * attempt * 5))
66+ done
67+ printf '%s\n' "$output" >&2
68+ return "$status"
69+ }
70+ BASH
71+4472 - name: Create ClawSweeper dispatch token
4573id: token
4674if: ${{ env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true' }}
77105 echo "::notice::Skipping GitHub activity dispatch because no ClawSweeper app token is configured."
78106 exit 0
79107 fi
108+ . "$RUNNER_TEMP/github-api-backoff.sh"
80109 activity="$(jq -c \
81110 --arg target_repo "$TARGET_REPO" \
82111 --arg event_name "$SOURCE_EVENT" \
@@ -143,7 +172,7 @@ jobs:
143172 ' "$GITHUB_EVENT_PATH")"
144173 payload="$(jq -nc --argjson activity "$activity" \
145174 '{event_type:"github_activity",client_payload:{activity:$activity}}')"
146- if gh api repos/openclaw/clawsweeper/dispatches \
175+ if gh_api_with_retry repos/openclaw/clawsweeper/dispatches \
147176 --method POST \
148177 --input - <<< "$payload"; then
149178 echo "Dispatched GitHub activity to ClawSweeper."
@@ -165,6 +194,7 @@ jobs:
165194 echo "::notice::Skipping ClawSweeper dispatch because no ClawSweeper app token is configured. Not falling back to a maintainer token."
166195 exit 0
167196 fi
197+ . "$RUNNER_TEMP/github-api-backoff.sh"
168198 payload="$(jq -nc \
169199 --arg target_repo "$TARGET_REPO" \
170200 --argjson item_number "$ITEM_NUMBER" \
@@ -173,7 +203,7 @@ jobs:
173203 --arg source_action "$SOURCE_ACTION" \
174204 --argjson supersedes_in_progress "$SUPERSEDES_IN_PROGRESS" \
175205 '{event_type:"clawsweeper_item",client_payload:{target_repo:$target_repo,item_number:$item_number,item_kind:$item_kind,source_event:$source_event,source_action:$source_action,supersedes_in_progress:$supersedes_in_progress}}')"
176- if gh api repos/openclaw/clawsweeper/dispatches \
206+ if gh_api_with_retry repos/openclaw/clawsweeper/dispatches \
177207 --method POST \
178208 --input - <<< "$payload"; then
179209 echo "Dispatched ClawSweeper review."
@@ -198,6 +228,7 @@ jobs:
198228 echo "::notice::Skipping ClawSweeper comment dispatch because no ClawSweeper app token is configured."
199229 exit 0
200230 fi
231+ . "$RUNNER_TEMP/github-api-backoff.sh"
201232 body_file="$RUNNER_TEMP/clawsweeper-comment-body.txt"
202233 printf '%s\n' "$COMMENT_BODY" > "$body_file"
203234 if ! grep -Eiq '(^|[[:space:]])@(clawsweeper|openclaw-clawsweeper)\b(\[bot\])?|(^|[[:space:]])/(clawsweeper|review|automerge|autoclose)\b' "$body_file"; then
@@ -206,7 +237,7 @@ jobs:
206237 fi
207238 if [ -n "$TARGET_TOKEN" ]; then
208239 err="$(mktemp)"
209- if GH_TOKEN="$TARGET_TOKEN" gh api -X POST \
240+ if GH_TOKEN="$TARGET_TOKEN" gh_api_with_retry -X POST \
210241 -H "Accept: application/vnd.github+json" \
211242 "repos/$TARGET_REPO/issues/comments/$COMMENT_ID/reactions" \
212243 -f content="eyes" 2>"$err" >/dev/null; then
@@ -233,7 +264,7 @@ jobs:
233264 "Command router queued. I will update this comment with the next step.")"
234265 status_payload="$(jq -nc --arg body "$status_body" '{body:$body}')"
235266 status_err="$(mktemp)"
236- if status_response="$(GH_TOKEN="$TARGET_TOKEN" gh api \
267+ if status_response="$(GH_TOKEN="$TARGET_TOKEN" gh_api_with_retry \
237268 "repos/$TARGET_REPO/issues/$ITEM_NUMBER/comments" \
238269 --method POST \
239270 --input - <<< "$status_payload" 2>"$status_err")"; then
@@ -254,7 +285,7 @@ jobs:
254285 --arg source_event "issue_comment" \
255286 --arg source_action "$SOURCE_ACTION" \
256287 '{event_type:"clawsweeper_comment",client_payload:({target_repo:$target_repo,item_number:$item_number,comment_id:$comment_id,source_event:$source_event,source_action:$source_action,max_comments:"1"} + (if $status_comment_id != "" then {status_comment_id:($status_comment_id|tonumber)} else {} end))}')"
257- if GH_TOKEN="$DISPATCH_TOKEN" gh api repos/openclaw/clawsweeper/dispatches \
288+ if GH_TOKEN="$DISPATCH_TOKEN" gh_api_with_retry repos/openclaw/clawsweeper/dispatches \
258289 --method POST \
259290 --input - <<< "$payload"; then
260291 echo "Dispatched ClawSweeper comment router."
@@ -276,6 +307,7 @@ jobs:
276307 echo "::notice::Skipping ClawSweeper commit dispatch because no ClawSweeper app token is configured. Not falling back to a maintainer token."
277308 exit 0
278309 fi
310+ . "$RUNNER_TEMP/github-api-backoff.sh"
279311 case "$CREATE_CHECKS" in
280312 true|TRUE|1|yes|YES|on|ON) create_checks=true ;;
281313 *) create_checks=false ;;
@@ -287,7 +319,7 @@ jobs:
287319 --arg ref "$SOURCE_REF" \
288320 --argjson create_checks "$create_checks" \
289321 '{event_type:"clawsweeper_commit_review",client_payload:{target_repo:$target_repo,before_sha:$before_sha,after_sha:$after_sha,ref:$ref,enabled:true,create_checks:$create_checks}}')"
290- if gh api repos/openclaw/clawsweeper/dispatches \
322+ if gh_api_with_retry repos/openclaw/clawsweeper/dispatches \
291323 --method POST \
292324 --input - <<< "$payload"; then
293325 echo "Dispatched ClawSweeper commit review."
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。