> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kugelaudio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on git push

> Connect a GitHub repository to a hosted agent so that every push to a branch builds the agent and puts it live once it passes its checks.

Connect your agent's GitHub repository once, and every push to its branch ships the
agent. Each push is built and checked first, and goes live only if it passes, so a
broken commit never replaces a working agent.

The repository holds an agent project, such as one created in the
[quickstart](/hosted-agents/quickstart). Commit its lockfile; keep `.env` out of git and
send your keys with [`curb secrets push`](/hosted-agents/deploy#curb-secrets-push) or on
the agent's **Variables** page.

## Connect a repository

<Steps>
  <Step title="Connect your GitHub account">
    Open your agent in the dashboard and go to **GitHub**. Choose **Connect GitHub** and
    authorize KugelAudio. You do this once; afterwards every agent in your organization
    picks repositories from the same list.
  </Step>
  <Step title="Install the GitHub App">
    Choose **Install GitHub App**. GitHub opens in a new tab, where you choose which
    accounts and repositories KugelAudio may read. The list in the dashboard updates when
    you come back.
  </Step>
  <Step title="Pick the repository and branch">
    | Field | What it means |
    |---|---|
    | **Repository** | The repository that holds the agent. |
    | **Branch** | The branch that ships. Defaults to the repository's default branch. |
    | **Root path** | Optional. The agent's directory when it is not at the top of the repository, for example `packages/agent`. |
    | **Deploy automatically on push** | On by default. Off means pushes are recorded but you deploy them yourself. |
  </Step>
  <Step title="Connect">
    With automatic deploys on, connecting deploys the branch's current head right away.
  </Step>
</Steps>

You can also start here when you create an agent: **Add your agent** has a
**Connect GitHub** button under **Use your own code**.

## What happens on a push

1. KugelAudio reads the pushed commit and builds the agent.
2. The new version starts and is checked.
3. If it passes, it goes live and takes the next calls. If it fails, the version that
   was live keeps answering.

Each step shows on the commit in GitHub as a status named **KugelAudio**: pending while
it builds, success when the version is live, failure when the build or the check fails.
The agent's **Deployments** page has every version with its build log.

When you push several times in a row, the newest push wins: an older push that has not
gone live yet does not replace a newer one.

## Turn automatic deploys off

With **Deploy automatically on push** off, every push is still read and listed under
**Deployments**. Choose **Make live** on the version you want to serve. This suits teams
that review a build before it takes calls.

## Disconnect

**Disconnect GitHub** removes your GitHub account from KugelAudio. Repositories that are
already connected keep deploying. To stop a repository from shipping, choose
**Disconnect repository** next to it on the agent's **GitHub** page.

## Next steps

<CardGroup cols={2}>
  <Card title="Web widget" icon="globe" href="/hosted-agents/web-widget">
    Put a talk button on your website
  </Card>
  <Card title="Phone numbers" icon="phone" href="/hosted-agents/phone-numbers">
    Give the agent a phone number
  </Card>
</CardGroup>
