From 292d2147c40cc9f0a66611fe2d26a894baee2dda Mon Sep 17 00:00:00 2001 From: Jaakko Heusala Date: Sun, 24 Aug 2025 15:50:08 +0300 Subject: [PATCH 1/3] Added PR workflow --- .github/workflows/pr.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..1cdc4db --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,43 @@ +name: PR updated → dispatch tocoding 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: + if: ${{ !github.event.pull_request.head.repo.fork && github.repository == 'hyperifyio/goagent' }} + runs-on: ubuntu-latest + 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: Send repository_dispatch to aibuddy + env: + DISPATCH_PAT: ${{ secrets.AIBUDDY_DISPATCH_PAT }} + run: | + curl -sSf -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${DISPATCH_PAT}" \ + https://api.github.com/repos/hyperifyio/aibuddy/dispatches \ + --data @payload.json From a9fe5f8aac6ae7e0c5b10630463cd9d54c3a43e7 Mon Sep 17 00:00:00 2001 From: Jaakko Heusala Date: Sun, 24 Aug 2025 15:59:46 +0300 Subject: [PATCH 2/3] Improved by using gh api instead --- .github/workflows/pr.yml | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1cdc4db..e545f50 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,5 @@ -name: PR updated → dispatch tocoding agent +name: PR updated → dispatch to coding agent + on: pull_request: types: [opened, reopened, synchronize, ready_for_review, edited] @@ -34,10 +35,35 @@ jobs: - name: Send repository_dispatch to aibuddy env: - DISPATCH_PAT: ${{ secrets.AIBUDDY_DISPATCH_PAT }} + GH_TOKEN: ${{ secrets.AIBUDDY_DISPATCH_PAT }} run: | - curl -sSf -X POST \ + set -euo pipefail + + # Secret present? + if [[ -z "${GH_TOKEN:-}" ]]; then + echo "::error title=Missing secret::AIBUDDY_DISPATCH_PAT is not set." + exit 1 + fi + + # Payload present? + if [[ ! -s payload.json ]]; then + echo "::error title=Missing payload::payload.json was not created." + exit 1 + fi + + # Validate JSON if jq exists + if command -v jq >/dev/null 2>&1; then + jq -e . payload.json >/dev/null || { + echo "::error title=Invalid JSON payload::payload.json is not valid JSON" + cat payload.json + exit 1 + } + fi + + # Dispatch (GitHub returns 204 No Content on success) + gh api repos/hyperifyio/aibuddy/dispatches \ + --method POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${DISPATCH_PAT}" \ - https://api.github.com/repos/hyperifyio/aibuddy/dispatches \ - --data @payload.json + --input payload.json + + echo "repository_dispatch sent successfully." From 93a39d3ebb99a459141c326f9b9087aaa8758cc3 Mon Sep 17 00:00:00 2001 From: Jaakko Heusala Date: Sun, 24 Aug 2025 16:01:23 +0300 Subject: [PATCH 3/3] Update .github/workflows/pr.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/pr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e545f50..15b25d5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,16 @@ permissions: contents: read pull-requests: read +env: + TARGET_REPOSITORY: hyperifyio/goagent + concurrency: group: pr-${{ github.event.pull_request.number }}-dispatch cancel-in-progress: true jobs: dispatch: - if: ${{ !github.event.pull_request.head.repo.fork && github.repository == 'hyperifyio/goagent' }} + if: ${{ !github.event.pull_request.head.repo.fork && github.repository == env.TARGET_REPOSITORY }} runs-on: ubuntu-latest steps: - name: Build payload