-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (66 loc) · 2.79 KB
/
pr.yml
File metadata and controls
77 lines (66 loc) · 2.79 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
name: PR updated → dispatch to coding agent
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, edited]
permissions:
contents: read
pull-requests: read
concurrency:
group: pr-${{ github.event.pull_request.number }}-dispatch
cancel-in-progress: true
jobs:
dispatch:
# Require: internal actor, not a fork, and PR targets main (tweak branch if needed)
if: ${{ !github.event.pull_request.head.repo.fork
&& contains(fromJSON('["thejhh","heusalagroupbot"]'), github.actor)
&& github.event.pull_request.base.ref == 'main' }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Build payload
id: payload
run: |
jq -n \
--arg repo "${{ github.repository }}" \
--argjson pr ${{ github.event.pull_request.number }} \
--arg sha "${{ github.event.pull_request.head.sha }}" \
--arg url "${{ github.event.pull_request.html_url }}" \
--arg head_repo "${{ github.event.pull_request.head.repo.full_name }}" \
--arg head_ref "${{ github.event.pull_request.head.ref }}" \
--arg base_ref "${{ github.event.pull_request.base.ref }}" \
'{event_type:"coding_agent_dispatch",
client_payload:{repo:$repo,pr:$pr,pr_head_sha:$sha,pr_html_url:$url,
head_repo:$head_repo,head_ref:$head_ref,base_ref:$base_ref}}' \
> payload.json
- name: Preflight (token & target repo access)
env:
GH_TOKEN: ${{ secrets.AIBUDDY_DISPATCH_PAT }}
run: |
set -euo pipefail
TARGET="hyperifyio/aibuddy"
if [[ -z "${GH_TOKEN:-}" ]]; then
echo "::error title=Missing secret::AIBUDDY_DISPATCH_PAT is not set."
exit 1
fi
# Verify token can see the private repo; prints a helpful error otherwise
if ! gh api "repos/$TARGET" >/dev/null 2>err.txt; then
echo "::error title=Token cannot access target repo::$TARGET not accessible with provided token."
cat err.txt || true
exit 1
fi
# Validate payload JSON
if [[ ! -s payload.json ]] || ! jq -e . payload.json >/dev/null; then
echo "::error title=Invalid payload::payload.json missing or not valid JSON"
[[ -f payload.json ]] && cat payload.json || true
exit 1
fi
- name: Send repository_dispatch to aibuddy (gh api)
env:
GH_TOKEN: ${{ secrets.AIBUDDY_DISPATCH_PAT }}
run: |
set -euo pipefail
gh api repos/hyperifyio/aibuddy/dispatches \
--method POST \
-H "Accept: application/vnd.github+json" \
--input payload.json
echo "repository_dispatch sent successfully."