# Deploy an existing App from CI



Commit the App source and `cluster.toml`. Keep `.ccp/` ignored so each runner selects its target explicitly. Set `CCP_SESSION_TOKEN` through your runner's secret store and set `ORG_ID` and `APP_ID` to the existing target IDs.

```bash
set -eu
export CCP_HEADLESS=1
ccp link --org-id "$ORG_ID" --app "$APP_ID"
receipt=$(ccp --json deploy --prod)
printf '%s\n' "$receipt" | jq -er --arg app "$APP_ID" \
  'select(.app_id == $app and .production == true) | .url'
```

Omit `--prod` for a preview and check for `.production == false`. The receipt contains the App, organization and deployment IDs, the URL, and the production flag. Diagnostic output goes to stderr. The shell stops if linking or deployment fails.

| Exit code | Meaning                                 |
| --------- | --------------------------------------- |
| 0         | Success                                 |
| 1         | Local or unclassified failure           |
| 2         | Invalid command or argument             |
| 3         | Authentication or authorization failure |
| 4         | Resource missing                        |
| 5         | Conflict or failed precondition         |
| 6         | Service, deadline or capacity failure   |

Review the error before retrying a mutation. A deadline can expire after the server accepts a request. Supply `--yes` on destructive commands only when the job is intended to perform the deletion. To run a repository build inside a Cluster Sandbox, see [CI builds](/docs/ccp/ci).
