ci: acknowledge pull request receipts in clawsweeper dispatch (#120934)

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.
This commit is contained in:
Peter Steinberger
2026-08-09 00:15:08 -07:00
committed by GitHub
parent 1b59c28164
commit adcf5bd93a
2 changed files with 67 additions and 1 deletions
@@ -118,6 +118,70 @@ jobs:
permission-issues: write
permission-pull-requests: read
- name: Create target PR acknowledgement token
id: pr_ack_token
if: >-
${{
github.event_name == 'pull_request_target' &&
(
github.event.action == 'ready_for_review' ||
(github.event.action == 'opened' && github.event.pull_request.draft == false)
) &&
env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true'
}}
continue-on-error: true
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-issues: write
- name: Acknowledge received pull request
if: >-
${{
github.event_name == 'pull_request_target' &&
(
github.event.action == 'ready_for_review' ||
(github.event.action == 'opened' && github.event.pull_request.draft == false)
) &&
env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true'
}}
continue-on-error: true
env:
ACK_TOKEN: ${{ steps.pr_ack_token.outputs.token }}
TARGET_REPO: ${{ github.repository }}
ITEM_NUMBER: ${{ github.event.pull_request.number }}
SOURCE_ACTION: ${{ github.event.action }}
run: |
set -euo pipefail
if [ -z "$ACK_TOKEN" ]; then
echo "::notice::Skipping ClawSweeper pull request acknowledgement because no target credential is configured."
exit 0
fi
comments="$(GH_TOKEN="$ACK_TOKEN" gh api \
"repos/$TARGET_REPO/issues/$ITEM_NUMBER/comments?per_page=100")"
if jq -e \
--arg marker_prefix "clawsweeper-pr-ack:" \
--arg marker_suffix " item=$ITEM_NUMBER -->" \
'any(.[]; (.body // "") as $body | ($body | contains($marker_prefix)) and ($body | contains($marker_suffix)))' \
<<< "$comments" >/dev/null; then
echo "ClawSweeper pull request acknowledgement already exists."
exit 0
fi
ack_body="$(printf '%s\n' \
"<!-- clawsweeper-pr-ack:$SOURCE_ACTION item=$ITEM_NUMBER -->" \
"🦞👀" \
"ClawSweeper picked this up." \
"" \
"Pull request received. I will update this pull request when review starts.")"
ack_payload="$(jq -nc --arg body "$ack_body" '{body:$body}')"
GH_TOKEN="$ACK_TOKEN" gh api \
"repos/$TARGET_REPO/issues/$ITEM_NUMBER/comments" \
--method POST \
--input - <<< "$ack_payload"
- name: Dispatch GitHub activity to ClawSweeper
env:
GH_TOKEN: ${{ steps.token.outputs.token }}