# Deploy from Git

> Connect a repository so every push deploys and production follows a branch.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/deploys/from-git/

For agents: Deploy from Git in Run: connect Sypnia Git (no app) or GitHub (Sypnia GitHub App: code read, checks and deployments write) with run git connect; push to production branch deploys to production; PR branches get previews with a PR comment; check runs; settings production.branch, production.auto=false (manual promote), ignore paths, root for monorepos; or CI with npx @sypnia/run deploy and a deploy token.

Connect a repository once; then a push to the production branch deploys to production, and any other push deploys a preview.

## Connect a repository

| Host                                 | How                                                                                                                                                            |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Sypnia Git](https://git.sypnia.com) | `run git connect sypnia:<org>/<repo>`: no app to install                                                                                                       |
| GitHub                               | `run git connect github:<owner>/<repo>`: installs the Sypnia GitHub App on the repository, with read access to code and write access to checks and deployments |

```bash
npx @sypnia/run git connect github:laespiga/web --production-branch main
```

## What happens on a push

| Push to                                  | Result                                                                                                                  |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| the production branch                    | a build; when it passes, production moves to the new deploy                                                             |
| another branch with an open pull request | a build and a [preview](https://run.docs.sypnia.com/deploys/previews); the pull request gets a comment with its address |
| any other branch                         | a build and a deploy reachable at its own address, if `branches` allows it                                              |

A check run on the commit says `building`, `ready` or `failed`, with a link to the logs.

## Settings

- `production.branch`: which branch is production (default `main`).
- `production.auto`: `false` makes production deploys wait for `run promote`.
- `ignore`: paths that do not trigger a build (`docs/**`), for monorepos.
- `root`: the app's folder in a monorepo.

## Without connecting

The CLI deploys a folder from any CI: `npx @sypnia/run deploy --env production --token "$SYPNIA_RUN_TOKEN"`, with a [deploy token](https://run.docs.sypnia.com/config/environment-and-secrets#deploy-tokens).
