# Repositories

> How an app is tied to a GitHub repository: connecting GitHub, the branch, deploy on push, the root directory, apps in a workspace, the lockfile, what is read.

An app is one GitHub repository, one branch and one folder of it. Every push to that branch deploys, unless you switch that off.

## Connect GitHub

The first time you create an app, choose **Connect GitHub** and pick the repositories we may read. Only an owner or an admin of the [team](https://arrangic.com/docs/teams.md) can do this. When you create an app, the list shows the repositories you picked that the person who connected can open on GitHub, so one member's connection never exposes a repository to a teammate who cannot see it there.

The list is a snapshot. GitHub does not tell us when someone loses access, so a list older than 30 days makes no new app until someone refreshes it: choose **Refresh** on the account, in the app form or under **Settings > Integrations**. Refresh takes a short trip to GitHub and lists what you can open now; only an owner or an admin can do it. Apps that already exist keep deploying in the meantime.

Is a repository missing from the list? Choose **Manage access on GitHub** and add it there, then **Refresh**.

## The branch

You pick the branch when you create the app, and you can change it under **Settings**, **Build & deploy**, **Source**. Only that branch deploys: a push to any other branch does nothing.

- **Auto deploy on push** is on for a new app: every push to the branch starts a deployment. Switch it off under **Settings**, **Build & deploy**, **Source** to deploy by hand only, with **Deploy** at the top of the app or the [deploy hook](https://arrangic.com/docs/deployments.md#deploy-hook).
- A branch that was renamed or removed fails the next deployment with "Branch ... was not found". Choose the branch under **Settings**, **Build & deploy**.
- A branch name starts with a letter or a digit, then letters, digits, dots, dashes, underscores and slashes. A branch with `#`, `+`, `@` or a space in its name cannot be chosen: "Enter the branch name as it is on GitHub: letters, digits, dots, dashes, underscores and slashes." An app already on such a branch keeps deploying until you save the branch again.

## What is read from the code

When you create the app, the dashboard reads the repository and fills in the settings:

| Read from | Fills in |
| --- | --- |
| `package.json`, its dependencies | The [framework](https://arrangic.com/docs/frameworks.md#how-the-framework-is-chosen). Set once, at creation |
| `package.json`, its scripts and `main` | The build and the start command |
| `.nvmrc`, then `engines.node` | The Node version |
| The lockfile | The package manager and the [install command](https://arrangic.com/docs/build-settings.md#install-command) |
| `prisma` among the dependencies | A [deploy command](https://arrangic.com/docs/deploy-commands.md), `npx prisma migrate deploy` |
| The framework | The port: 3000, or the framework's own (4321 for Astro, 3333 for AdonisJS) |

Later the settings do not follow the repository by themselves: change them under **Settings**, **Build & deploy**. See [Build settings](https://arrangic.com/docs/build-settings.md).

## Root directory

Leave it empty when `package.json` is at the top of the repository. Set it to a folder, `apps/api` for example, when the app lives in one.

A folder with a lockfile of its own is built by itself. Only that folder becomes the app, and files outside it are not there.

One repository can back several apps: one per branch, or one per folder.

## An app in a workspace

A folder that has a `package.json` but no lockfile of its own is part of a workspace: npm, pnpm or Yarn workspaces, with or without a task runner on top. It belongs to the nearest folder above it that has a `package.json` and a lockfile. Most often that is the top of the repository.

When the repository you pick for a new app is a workspace at its top (`workspaces` in `package.json`, or a `pnpm-workspace.yaml`), the form lists the folders of the workspace that have a `package.json` and asks which one is the app. Pick one: it becomes the root directory, and the folder is read for the framework and the commands. **Change** next to the folder opens the list again, and the top of the repository can be chosen instead. For an app that exists, set the folder as the root directory under **Settings**, `apps/web` for example. Then:

- **Packages are installed from the top of the workspace,** with the package manager of the lockfile there. An install command of your own runs there too.
- **The build commands and the start command run in the folder of the app.**

There is nothing else to set. The form for a new app says when a folder is part of a workspace, and the deployment log says where the packages are installed and where the app runs. One repository backs as many apps as it has folders: create an app per folder.

Three things to know:

- **Every package of the workspace is installed.** To install less, set an install command of your own.
- **A neighbour package is not built for you.** When the app needs one that has to be built first, put that build into the build commands, before the build of the app.
- **The workspace needs a lockfile at its top.** Commit it.

## The lockfile

Commit your lockfile and keep it in step with `package.json`. It decides the package manager, and with pnpm, Yarn and Bun a lockfile that does not match fails the build. Two lockfiles are a mistake. See [Package manager](https://arrangic.com/docs/build-settings.md#package-manager).

## Limits

- The repository takes at most 2 GB on GitHub with its history, the archive of the commit that is built at most 512 MB, and it unpacks to at most 4 GB and 1,000,000 files. See [How an app is built](https://arrangic.com/docs/builds.md#limits).
- A `Dockerfile` in it is ignored: the app is built from `package.json`. See [How an app is built](https://arrangic.com/docs/builds.md).

---

This page on the site: https://arrangic.com/docs/repositories  
All pages of the documentation: https://arrangic.com/llms.txt
