# GitHub & Registry Integrations

> Connect ZopNight to GitHub for source, builds, and webhooks, and to container registries (ECR, GAR, ACR, Docker Hub) for image push/pull.

Source: https://zop.dev/developer-docs/integrations

---

Integrations are the external systems ZopNight reaches into when you deploy. The most important one today is GitHub: ZopNight authenticates as a GitHub App, lists your repos, kicks off Actions-based builds, and receives push/PR [webhooks](https://zop.dev/docs/deployments/webhooks). Container registry credentials (ECR, GAR, ACR, Docker Hub) are stored alongside in the same integrations table.

**Info**

Most orgs have exactly one GitHub integration (the org-level GitHub App installation) and one registry per cloud account. You can have more if you split across GitHub orgs or maintain separate registries per environment.

## GitHub App Installation

1. The user clicks "Connect GitHub" in ZopNight.
2. ZopNight redirects to GitHub's app install page via `GET /integrations/github/install`.
3. GitHub redirects back with an installation ID, which lands on `GET /integrations/github/callback`.
4. ZopNight stores the installation, exchanges short-lived tokens at deploy time, and starts receiving webhooks.

### GET /integrations/github/install

Initiates the GitHub App install flow. Returns a redirect to the GitHub App install page.

### GET /integrations/github/callback

OAuth/install callback. ZopNight finalizes the installation and stores the integration record.

## Manage Integrations

### GET /integrations

List integrations.

```json title="Response"
{
  "data": [
    {
      "id": "int_github_001",
      "kind": "github",
      "name": "Acme GitHub Org",
      "metadata": { "installationID": 12345678, "githubOrg": "acme" },
      "createdAt": "2026-04-01T10:00:00Z"
    },
    {
      "id": "int_ecr_001",
      "kind": "ecr",
      "name": "ECR — production AWS",
      "metadata": {
        "registry": "123456789012.dkr.ecr.us-east-1.amazonaws.com",
        "cloudAccountID": "ca_abc123"
      },
      "createdAt": "2026-04-02T08:00:00Z"
    }
  ]
}
```

### POST /integrations

Create an integration. Most flows go through the connect endpoints (GitHub install, GCP OAuth) — this is the manual path for static credentials (e.g. Docker Hub username/password).

```bash title="Request — Docker Hub registry"
curl -X POST https://zopnight.com/api/integrations \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "dockerhub",
    "name": "Docker Hub — acme",
    "credentials": {
      "username": "acme-bot",
      "password": "..."
    }
  }'
```

### GET /integrations/{id}

Get an integration by ID. Secrets are never returned.

### PUT /integrations/{id}

Update an integration (display name, metadata, or rotated credentials).

### DELETE /integrations/{id}

Delete an integration. Deployments referencing it will fail until reassigned. GitHub integrations also revoke the installation on GitHub

## Supported Integration Kinds

| Kind | Used for | Auth |
|---|---|---|
| `github` | Source code, build dispatch, webhooks | GitHub App installation token (short-lived) |
| `ecr` | Container image push/pull (AWS) | Inherits the bound cloud account |
| `gar` | Container image push/pull (GCP) | Inherits the bound cloud account |
| `acr` | Container image push/pull (Azure) | Inherits the bound cloud account |
| `dockerhub` | Container image push/pull (Docker Hub) | Username + password / access token |

For the MCP integration (AI assistants connecting to ZopNight) see [MCP Server](https://zop.dev/docs/integrations/mcp-server/overview).
