forked from openclaw/clawsweeper
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (155 loc) · 6.46 KB
/
Copy pathgithub-activity.yml
File metadata and controls
168 lines (155 loc) · 6.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: github activity to openclaw
on:
repository_dispatch:
types:
- github_activity
issues:
types:
- opened
- reopened
- edited
- closed
- labeled
- unlabeled
- assigned
- unassigned
issue_comment:
types:
- created
- edited
pull_request_target:
types:
- opened
- reopened
- synchronize
- ready_for_review
- converted_to_draft
- edited
- closed
- labeled
- unlabeled
pull_request_review:
types:
- submitted
- edited
- dismissed
pull_request_review_comment:
types:
- created
- edited
workflow_run:
workflows:
- sweep
- repair cluster worker
- repair publish cluster results
- commit review
types:
- completed
permissions:
contents: write
actions: read
issues: read
pull-requests: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
concurrency:
group: >-
github-activity-${{ github.event.client_payload.activity.repo || github.event.client_payload.target_repo || github.event.repository.full_name || github.repository }}-${{ github.event_name == 'workflow_run' && 'workflow-run' || format('{0}-{1}-{2}-{3}', github.event.client_payload.event_name || github.event.client_payload.activity.type || github.event_name, github.event.client_payload.action || github.event.client_payload.activity.action || github.event.action || 'activity', github.event.client_payload.comment_id || github.event.client_payload.review_comment_id || github.event.client_payload.activity.comment.id || github.event.comment.id || github.event.client_payload.activity.review.id || github.event.review.id || github.event.client_payload.activity.workflow_run.id || github.event.workflow_run.id || github.event.client_payload.activity.pull_request.number || github.event.pull_request.number || github.event.client_payload.activity.issue.number || github.event.issue.number || github.event.client_payload.activity.subject.number || github.event.client_payload.number || github.run_id, github.event.client_payload.activity.label.name || github.event.label.name || github.event.client_payload.activity.assignee.login || github.event.assignee.login || github.event.client_payload.activity.pull_request.head.sha || github.event.pull_request.head.sha || github.event.client_payload.activity.delivery_id || github.event.client_payload.delivery_id || github.event.client_payload.activity.idempotency_key || github.event.client_payload.idempotency_key || github.run_attempt) }}
cancel-in-progress: true
jobs:
notify:
if: >-
${{
!(github.event_name == 'pull_request_target' && github.event.action == 'synchronize') &&
!(github.event_name == 'repository_dispatch' && github.event.client_payload.activity.type == 'pull_request_target' && github.event.client_payload.activity.action == 'synchronize') &&
!(github.event_name == 'workflow_run' && contains(fromJSON('["success","neutral","skipped"]'), github.event.workflow_run.conclusion))
}}
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Check core API budget
id: core-budget
env:
GH_TOKEN: ${{ github.token }}
MIN_CORE_REMAINING: ${{ vars.CLAWSWEEPER_MIN_CORE_REMAINING || '250' }}
run: |
set -euo pipefail
budget="$(gh api rate_limit --jq '[.resources.core.remaining, .resources.core.reset] | @tsv')"
remaining="${budget%%$'\t'*}"
reset="${budget##*$'\t'}"
threshold="$MIN_CORE_REMAINING"
if [ "$remaining" -lt "$threshold" ]; then
reset_iso="$(date -u -d "@$reset" '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || echo "$reset")"
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Skipping noncritical GitHub activity notification; core remaining=$remaining threshold=$threshold reset=$reset_iso."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v7
if: steps.core-budget.outputs.skip != 'true'
with:
ref: ${{ github.event.repository.default_branch }}
filter: blob:none
persist-credentials: false
- uses: actions/setup-node@v6
if: steps.core-budget.outputs.skip != 'true'
with:
node-version: "24"
- name: Enable pinned pnpm
if: steps.core-budget.outputs.skip != 'true'
shell: bash
run: |
set -euo pipefail
corepack enable
for attempt in 1 2 3; do
if corepack prepare "pnpm@11.10.0" --activate; then
exit 0
fi
sleep "$((attempt * 10))"
done
corepack prepare "pnpm@11.10.0" --activate
- name: Resolve pnpm store
id: pnpm-store
if: steps.core-budget.outputs.skip != 'true'
shell: bash
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v6
if: steps.core-budget.outputs.skip != 'true'
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: ${{ runner.os }}-pnpm-11.10.0-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-11.10.0-
${{ runner.os }}-pnpm-
- name: Install dependencies
if: steps.core-budget.outputs.skip != 'true'
shell: bash
run: |
set -euo pipefail
for attempt in 1 2 3; do
if pnpm install --frozen-lockfile; then
break
fi
if [ "$attempt" -eq 3 ]; then
exit 1
fi
sleep "$((attempt * 10))"
done
pnpm run build:repair
- name: Dispatch spam scan candidate
if: steps.core-budget.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
pnpm run repair:spam-comment-intake -- --write-report
- name: Feed activity to OpenClaw
if: steps.core-budget.outputs.skip != 'true'
env:
CLAWSWEEPER_OPENCLAW_HOOK_URL: ${{ secrets.CLAWSWEEPER_OPENCLAW_HOOK_URL }}
CLAWSWEEPER_OPENCLAW_HOOK_TOKEN: ${{ secrets.CLAWSWEEPER_OPENCLAW_HOOK_TOKEN }}
CLAWSWEEPER_OPENCLAW_AGENT_ID: ${{ vars.CLAWSWEEPER_OPENCLAW_AGENT_ID || 'clawsweeper' }}
CLAWSWEEPER_DISCORD_TARGET: ${{ vars.CLAWSWEEPER_DISCORD_TARGET }}
run: |
set -euo pipefail
pnpm run repair:notify-github-activity -- --write-report