
# The app's GitHub repo

Each app's code is in a private repo in Agent Cloud's GitHub organization, `agentcloud-apps/<app>`, with one commit per live release. Pushes and merges don't deploy: only `agc ship` does. Whoever manages the app can join it as a maintainer, or move it to their own GitHub, from the app's settings.

```bash
agc ship        # each release that reaches "outcome": "live" becomes one commit on main
```

## Ask your agent

```text
Where does camp-bookings' code live on GitHub, and how do I get access?
```

The agent points the person to the app's settings in the console; it can't invite anyone itself.

## Steps

**Join the repo.** In the console, open the app's settings, **Code** section, **Get maintainer access**: enter your GitHub username and press **Invite me**. GitHub sends an invite; you get the `maintain` role.

**Take it to your GitHub.** In the app's settings, **Danger zone**, **Take the repo to your GitHub**: enter your GitHub username, type the app's name to confirm, and press **Transfer the repo**. Accept the transfer on GitHub within a day. From then on the repo is yours and Agent Cloud stops pushing releases to it.

## How it works

**When it's made.** Control makes the repo when the app has a live release and no repo yet: private, `main` initialized, no issues, wiki or projects, with the app's URL as its homepage. A sweep runs at start and every ten minutes.

**One commit per live release.** After a release goes live, control writes a commit on `main` whose tree is that release's snapshot, titled from the ship's message (or "First release", "Release v12"). Files are filtered twice before anything is committed, since a shared commit can't be pulled back:

| Left out | Why |
|---|---|
| `.env` files (except `.env.example`, `.env.sample`, `.env.template`), `.npmrc`, `.netrc`, `.pypirc`, `.git-credentials`, SSH keys, `*.pem`, `*.key`, `*.p12`, local databases and dumps | Secrets or local data, by name |
| Files containing a private key, an AWS access key, a GitHub, Slack or Agent Cloud token, a live API secret key, or a Postgres URL with a password for a non-local host | Secrets, by content |
| Files over 50 MB, or paths GitHub would refuse | Size and path rules |
| Files under `.github/workflows/` | Agent Cloud's GitHub App doesn't write workflow files |

Each left-out file is named in a `repo.file_skipped` event, never its content. `[[asset]]` files are listed in an `ASSETS.md` instead of committed. A repo with no README gets one.

**`main` is protected.** Every repo gets one ruleset, `agent.cloud: main is protected`. `main` can't be deleted or force-pushed, and changes reach it only through a pull request. Only Agent Cloud's GitHub App bypasses it, so a maintainer can't push to `main` directly or edit the ruleset. The sweep re-applies the ruleset at least hourly, so a removed or weakened one comes back. A failure is recorded as `repo.unprotected` and never holds up a release.

**Merging a PR doesn't deploy.** A merged PR stays on `main`, not live, until someone ships, and `agc status` reports it as `merged_not_live`. Ship from a clean, up-to-date checkout of `main` (`git pull`, then `agc ship`) and the release lands on `main`. When a ship names a commit that contains `main` (a builder's PR head, for example), its release commit on `main` is that commit's merge, so the PR shows merged on GitHub once the release is live.

**When a release can't go on `main`.** If `main` has work the release doesn't, the release commit becomes tag `v<N>` and control asks GitHub to merge the tag into `main`, keeping both sides (`repo.release_merged_to_main`). If that merge conflicts or is refused, `main` is left as it is (`repo.release_not_on_main`) and control files one Work item, "Bring main and production back together": merge tag `v<N>` into `main`, then ship from `main`. With the builder on, it takes the item; otherwise `agc status` and `agc ship` show `data.main_apart` (`item`, `url`, `tag`, `message`) with `agc work show <item>` in `next`. The next release that lands on `main` ends the item.

**Transfer.** A transfer GitHub hasn't completed after 25 hours is dropped (`repo.transfer_expired`) and can be asked again. A transferred repo keeps the ruleset, administered by its new owner.

**Delete and restore.** Deleting the app archives the repo rather than deleting it: read-only, described as "deleted from Agent Cloud on <date>". Restoring the app un-archives it and protects it again. A repo already transferred is never touched.

## Reference

| Event | When |
|---|---|
| `repo.created` | Repo made |
| `repo.protected` / `repo.unprotected` | Ruleset applied / couldn't be applied |
| `repo.release_on_main` / `repo.release_not_on_main` | A release's commit landed on `main` / only as tag `v<N>` |
| `repo.release_merged_to_main` | Tag `v<N>` was merged into `main` |
| `repo.apart_item` | The "Bring main and production back together" Work item was filed or added to |
| `repo.file_skipped` | A file left out of a release's commit |
| `repo.invited` / `repo.transferred` / `repo.transfer_expired` | Console actions and their outcome |
| `repo.archived` / `repo.unarchived` | App deleted / restored |

## Errors

`agc repo retry` asks Agent Cloud to try a failed repo sync again now. It needs a credential that may ship the app. When `agc status` doesn't show `data.repo.state` as `failed`, it answers `repo.nothing_to_retry` (exit 1). The console's settings page reports invite and transfer outcomes under its own key: a username that isn't a GitHub username, a typed name that doesn't match, a repo already transferred, or a GitHub failure.


A CLI setup failure, before the operation runs: if the machine has an identity but the current folder has no manifest, `agc ship` exits 1. Run it from the linked app folder, or initialize that repository.

```json
{
  "ok": false,
  "product": "agent.cloud",
  "command": "ship",
  "error": {
    "retryable": false,
    "code": "app.not_linked",
    "message": "No agentcloud.toml in this directory or above it.",
    "fix": "Run `agc init` in the app repository.",
    "docs": "agc help onboarding"
  },
  "next": [
    {
      "cmd": "agc init",
      "why": "create the app on agent.cloud and write agentcloud.toml"
    }
  ]
}
```

## Limits

- 50 MB per committed file. Transfer acceptance: about one day.

## Agent notes

- Don't `git push` or merge to the app's repo to deploy; it does nothing for production.
- To make the repo public, transfer it to your GitHub first; the `maintain` role can't change visibility.
- With `data.main_apart` in an answer, run `agc work show <item>`: merge tag `v<N>` into `main`, keeping both sides, then ship from `main`.
- Never rely on the repo for secrets you committed by accident: they're left out, but they were still in your snapshot. Remove them and rotate them.

## Related

- [Deleting and restoring an app](/docs/ship/deleting-and-restoring-an-app.md)
- [agc ship, end to end](/docs/ship/agc-ship-end-to-end.md)
- [CI/CD with deploy keys](/docs/ship/ci-cd-with-deploy-keys.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "ship/the-apps-github-repo: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
