























@@ -3,6 +3,8 @@ name: ClawSweeper Dispatch
33on:
44issues:
55types: [opened, reopened, edited, labeled, unlabeled]
6+issue_comment:
7+types: [created, edited]
68push:
79branches: [main]
810pull_request_target: # zizmor: ignore[dangerous-triggers] maintainer-owned external dispatch; no checkout or untrusted PR code execution
@@ -18,7 +20,7 @@ concurrency:
1820jobs:
1921dispatch:
2022runs-on: ubuntu-latest
21-if: ${{ !(endsWith(github.actor, '[bot]') && (github.event.action == 'labeled' || github.event.action == 'unlabeled')) }}
23+if: ${{ github.event_name == 'issue_comment' || !(endsWith(github.actor, '[bot]') && (github.event.action == 'labeled' || github.event.action == 'unlabeled')) }}
2224env:
2325HAS_CLAWSWEEPER_APP_PRIVATE_KEY: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY != '' }}
2426CLAWSWEEPER_APP_CLIENT_ID: Iv23liOECG0slfuhz093
@@ -39,8 +41,20 @@ jobs:
3941repositories: clawsweeper
4042permission-contents: write
414344+ - name: Create target comment token
45+id: target_token
46+if: ${{ github.event_name == 'issue_comment' && env.HAS_CLAWSWEEPER_APP_PRIVATE_KEY == 'true' }}
47+uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
48+with:
49+client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
50+private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
51+owner: ${{ github.repository_owner }}
52+repositories: ${{ github.event.repository.name }}
53+permission-issues: write
54+permission-pull-requests: read
55+4256 - name: Dispatch exact ClawSweeper review
43-if: ${{ github.event_name != 'push' }}
57+if: ${{ github.event_name != 'push' && github.event_name != 'issue_comment' }}
4458env:
4559GH_TOKEN: ${{ steps.token.outputs.token }}
4660TARGET_REPO: ${{ github.repository }}
@@ -69,6 +83,60 @@ jobs:
6983 echo "::warning::Skipping ClawSweeper dispatch because the configured credential could not dispatch to openclaw/clawsweeper."
7084 fi
718586+ - name: Acknowledge and dispatch ClawSweeper comment
87+if: ${{ github.event_name == 'issue_comment' }}
88+env:
89+DISPATCH_TOKEN: ${{ steps.token.outputs.token }}
90+TARGET_TOKEN: ${{ steps.target_token.outputs.token }}
91+TARGET_REPO: ${{ github.repository }}
92+ITEM_NUMBER: ${{ github.event.issue.number }}
93+COMMENT_ID: ${{ github.event.comment.id }}
94+COMMENT_BODY: ${{ github.event.comment.body }}
95+SOURCE_ACTION: ${{ github.event.action }}
96+run: |
97+ set -euo pipefail
98+ if [ -z "$DISPATCH_TOKEN" ]; then
99+ echo "::notice::Skipping ClawSweeper comment dispatch because no ClawSweeper app token is configured."
100+ exit 0
101+ fi
102+ body_file="$RUNNER_TEMP/clawsweeper-comment-body.txt"
103+ printf '%s\n' "$COMMENT_BODY" > "$body_file"
104+ if ! grep -Eiq '(^|[[:space:]])@clawsweeper\b|(^|[[:space:]])/(clawsweeper|review|automerge|autoclose)\b' "$body_file"; then
105+ echo "No ClawSweeper command found in comment."
106+ exit 0
107+ fi
108+ if [ -n "$TARGET_TOKEN" ]; then
109+ err="$(mktemp)"
110+ if GH_TOKEN="$TARGET_TOKEN" gh api -X POST \
111+ -H "Accept: application/vnd.github+json" \
112+ "repos/$TARGET_REPO/issues/comments/$COMMENT_ID/reactions" \
113+ -f content="eyes" 2>"$err" >/dev/null; then
114+ echo "Acknowledged ClawSweeper command comment."
115+ elif grep -qi "HTTP 422\\|already exists" "$err"; then
116+ echo "ClawSweeper command comment already acknowledged."
117+ else
118+ cat "$err" >&2
119+ echo "::warning::Could not acknowledge ClawSweeper command comment."
120+ fi
121+ rm -f "$err"
122+ else
123+ echo "::notice::Skipping ClawSweeper comment acknowledgement because no target token is configured."
124+ fi
125+ payload="$(jq -nc \
126+ --arg target_repo "$TARGET_REPO" \
127+ --argjson item_number "$ITEM_NUMBER" \
128+ --argjson comment_id "$COMMENT_ID" \
129+ --arg source_event "issue_comment" \
130+ --arg source_action "$SOURCE_ACTION" \
131+ '{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}}')"
132+ if GH_TOKEN="$DISPATCH_TOKEN" gh api repos/openclaw/clawsweeper/dispatches \
133+ --method POST \
134+ --input - <<< "$payload"; then
135+ echo "Dispatched ClawSweeper comment router."
136+ else
137+ echo "::warning::Skipping ClawSweeper comment dispatch because the configured credential could not dispatch to openclaw/clawsweeper."
138+ fi
139+72140 - name: Dispatch ClawSweeper commit review
73141if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.deleted != true }}
74142env:
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。