Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

cursor-hygiene-webhook.yml

52 lines1.8 KB

1name: Forward to Cursor hygiene
2​
3on:
4 push:
5 branches: [main]
6 # Use trusted workflow code and repository secrets for fork PRs.
7 # Keep this job payload-only: never check out or run PR code.
8 pull_request_target:
9 types: [opened, reopened, ready_for_review]
10 issues:
11 types: [opened, closed, reopened]
12 discussion:
13 types: [created, closed, reopened]
14​
15permissions:
16 contents: read
17​
18jobs:
19 forward:
20 name: POST to Cursor
21 runs-on: ubuntu-24.04
22 steps:
23 - name: POST to Cursor
24 env:
25 URL: ${{ secrets.CURSOR_T3CODE_WEBHOOK_URL }}
26 AUTH: ${{ secrets.CURSOR_T3CODE_WEBHOOK_AUTH }}
27 run: |
28 set -euo pipefail
29 if [ -z "${URL:-}" ] || [ -z "${AUTH:-}" ]; then
30 echo "Missing CURSOR_T3CODE_WEBHOOK_URL or CURSOR_T3CODE_WEBHOOK_AUTH — skipping."
31 exit 0
32 fi
33 for attempt in 1 2 3; do
34 curl_status=0
35 http_status=$(curl -fsS --max-time 60 -X POST "$URL" \
36 --output /dev/null --write-out '%{http_code}' \
37 -H "Authorization: $AUTH" \
38 -H "Content-Type: application/json" \
39 -H "X-GitHub-Event: ${{ github.event_name == 'pull_request_target' && 'pull_request' || github.event_name }}" \
40 -H "X-GitHub-Delivery: ${{ github.run_id }}-${{ github.run_attempt }}" \
41 --data-binary @"${{ github.event_path }}") || curl_status=$?
42 if [ "$curl_status" -eq 0 ]; then
43 exit 0
44 fi
45 if [ "$GITHUB_REF" != "refs/heads/main" ] || \
46 [ "$curl_status" -ne 22 ] || [ "$http_status" != "400" ] || \
47 [ "$attempt" -eq 3 ]; then
48 exit "$curl_status"
49 fi
50 echo "Cursor webhook returned HTTP 400; retrying in 5 seconds ($attempt/2)."
51 sleep 5
52 done