Skip to content

Commit 9726f3c

Browse files
committed
ci: acknowledge pull request receipts in clawsweeper dispatch
Propagate the receipt-acknowledgment steps from the canonical ClawSweeper dispatch template (openclaw/clawsweeper#1080): mint a minimal issues:write App token and post an idempotent clawsweeper-pr-ack marker comment for non-draft opened and ready_for_review pull requests, before review dispatch.
1 parent 562129d commit 9726f3c

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

‎.github/workflows/clawsweeper-dispatch.yml‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,70 @@ jobs:
118118
permission-issues: write
119119
permission-pull-requests: read
120120

121+
- name: Create target PR acknowledgement token
122+
id: pr_ack_token
123+
if: >-
124+
${{
125+
github.event_name == 'pull_request_target' &&
126+
(
127+
github.event.action == 'ready_for_review' ||
128+
(github.event.action == 'opened' && github.event.pull_request.draft == false)
129+
) &&
130+
env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true'
131+
}}
132+
continue-on-error: true
133+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
134+
with:
135+
client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
136+
private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
137+
owner: ${{ github.repository_owner }}
138+
repositories: ${{ github.event.repository.name }}
139+
permission-issues: write
140+
141+
- name: Acknowledge received pull request
142+
if: >-
143+
${{
144+
github.event_name == 'pull_request_target' &&
145+
(
146+
github.event.action == 'ready_for_review' ||
147+
(github.event.action == 'opened' && github.event.pull_request.draft == false)
148+
) &&
149+
env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true'
150+
}}
151+
continue-on-error: true
152+
env:
153+
ACK_TOKEN: ${{ steps.pr_ack_token.outputs.token }}
154+
TARGET_REPO: ${{ github.repository }}
155+
ITEM_NUMBER: ${{ github.event.pull_request.number }}
156+
SOURCE_ACTION: ${{ github.event.action }}
157+
run: |
158+
set -euo pipefail
159+
if [ -z "$ACK_TOKEN" ]; then
160+
echo "::notice::Skipping ClawSweeper pull request acknowledgement because no target credential is configured."
161+
exit 0
162+
fi
163+
comments="$(GH_TOKEN="$ACK_TOKEN" gh api \
164+
"repos/$TARGET_REPO/issues/$ITEM_NUMBER/comments?per_page=100")"
165+
if jq -e \
166+
--arg marker_prefix "clawsweeper-pr-ack:" \
167+
--arg marker_suffix " item=$ITEM_NUMBER -->" \
168+
'any(.[]; (.body // "") as $body | ($body | contains($marker_prefix)) and ($body | contains($marker_suffix)))' \
169+
<<< "$comments" >/dev/null; then
170+
echo "ClawSweeper pull request acknowledgement already exists."
171+
exit 0
172+
fi
173+
ack_body="$(printf '%s\n' \
174+
"<!-- clawsweeper-pr-ack:$SOURCE_ACTION item=$ITEM_NUMBER -->" \
175+
"🦞👀" \
176+
"ClawSweeper picked this up." \
177+
"" \
178+
"Pull request received. I will update this pull request when review starts.")"
179+
ack_payload="$(jq -nc --arg body "$ack_body" '{body:$body}')"
180+
GH_TOKEN="$ACK_TOKEN" gh api \
181+
"repos/$TARGET_REPO/issues/$ITEM_NUMBER/comments" \
182+
--method POST \
183+
--input - <<< "$ack_payload"
184+
121185
- name: Dispatch GitHub activity to ClawSweeper
122186
env:
123187
GH_TOKEN: ${{ steps.token.outputs.token }}

‎docs/reference/pull-request-review-flow.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ and help maintainers with guarded repair or automerge flows.
4545
A positive ClawSweeper result is supporting evidence, not maintainer approval.
4646
Maintainers still decide whether and when a PR is ready to merge.
4747

48-
ClawSweeper is queue-based. Do not expect an immediate response after opening a
48+
ClawSweeper is queue-based. When you open a non-draft PR or mark a draft ready
49+
for review, it posts a short receipt comment right away, but the review itself
50+
still waits for a queue slot. Do not expect an immediate review after opening a
4951
PR, pushing a commit, or adding a review request. Label updates after a
5052
ClawSweeper run can also take time.
5153

0 commit comments

Comments
 (0)