Skip to main content

GitHub

Connecting GitHub lets 4RGE read repositories, open pull requests, and react to events for cloud agents and automations. The GitHub integration is the most complete source-control integration today — required for repository-scoped cloud runs and webhook-driven automations.

Connecting

  1. Install the GitHub app

    From the Integrations page in the dashboard, install the 4RGE GitHub app on your organization or personal account.

  2. Grant repository access

    Choose which repositories 4RGE may access — all repositories, or a selected set. Start with a minimal set and expand as teams onboard.

  3. Confirm the connection

    The Integrations page shows connection status once installation completes. The agents API reports installation health at /api/github/app/status.

  4. Sync repositories

    Trigger a repository sync so branches and metadata appear in the Agents workspace picker. In production this happens automatically; locally it may require the Supabase service role key (see Troubleshooting).

Dashboard connect flow

From Dashboard → Integrations, GitHub is the only source-control provider with a live connect path today. Clicking Connect calls /api/github/app/connect, which verifies your org scope, checks for an existing installation in x4rge_github_installations, and redirects to the GitHub App install URL. After GitHub redirects back to /api/github/app/callback, 4RGE syncs repositories into x4rge_repositories and records a github.installation.sync audit event.

Local development

The connect flow requires SUPABASE_SERVICE_ROLE_KEY in agents-api locally. Without it, the API returns 503 and repository metadata sync is limited even if GitHub authorization succeeds.

Repository sync and recovery

Repository metadata syncs automatically on install, on installation_repositories webhooks, and when an operator calls the manual sync endpoint:

curl -X POST "https://agents-api.4rged.ai/api/github/installations/sync" \
  -H "Authorization: Bearer <session-access-token>" \
  -H "Content-Type: application/json" \
  -d '{ "organizationId": "org_abc123", "installationId": 12345678 }'

If repos are missing in the Agents workspace picker after a successful install, run manual sync and confirm the GitHub app has access to those repositories in GitHub's app settings.

What it enables

CapabilityUsed by
Clone and branchCloud agent runs
Open and update pull requestsCloud agents, automations
Read check runs and CI status"Fix failing CI" automations
Webhook deliveryGitHub-triggered automations
Repository and branch listingAgents workspace UI

Webhook events

4RGE receives GitHub webhooks at the agents API and matches them to automations scoped to the repository:

EventTypical automation use
pull_requestReview on open, fix on failing checks
check_runReact to CI failure
issue_commentSlash-command or mention triggers
pushPost-merge doc generation
installationSync repos when app access changes
Webhook handlers today

The agents-api webhook route actively processes installation, installation_repositories, and pull_request events. Other event types are acknowledged but ignored until matching automations ship. PR webhooks can enqueue reviewer runs when the repository is registered in 4RGE.

API endpoints

Install and manage the GitHub app through the agents API (session-authenticated, org-scoped):

# Check installation status
curl "https://agents-api.4rged.ai/api/github/app/status?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"
 
# List connected repositories
curl "https://agents-api.4rged.ai/api/github/repositories?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"
 
# List branches for a repository
curl "https://agents-api.4rged.ai/api/github/repositories/42/branches?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"

Start a cloud run that opens a PR when complete:

curl -X POST "https://agents-api.4rged.ai/api/agent-runs/org_abc123/run_xyz/github/pull-request" \
  -H "Authorization: Bearer <session-access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "fix: resolve flaky auth test",
    "body": "Automated fix from cloud agent run run_xyz",
    "base": "main"
  }'

Permissions model

PermissionWhy 4RGE needs it
Repository contents (read/write)Clone, commit, push branches
Pull requests (read/write)Open and update PRs from agent runs
Checks (read)Inspect CI conclusions for automations
Metadata (read)List repos and branches
Note

Grant access to only the repositories you need. You can expand access later from GitHub's app settings without reinstalling the 4RGE app.

Operator checklist

  • GitHub app installed on the correct org/account
  • Repository allowlist matches teams using cloud agents
  • Webhook deliveries succeed (check Sentinel or operations summary)
  • Branch protection rules allow bot PRs or require human review as intended
  • Secrets for private submodule access configured in cloud agent environment