# Connect GitHub

Connect your Spice.ai project to a GitHub repository

## Prepare the repository

Before connecting:

- **Admin access**: Ensure you have administrative access to the GitHub repository. This level of access is required to [install the Spice.ai GitHub app](https://docs.github.com/en/apps/using-github-apps/installing-a-github-app-from-github-marketplace-for-your-organizations#requirements-to-install-a-github-app-on-an-organization).
- **Repository owner**: The repository must belong to the GitHub organization or account that the **Connect @\<owner>** button shows. This owner is usually the name of your Spice.ai org. The repository name can differ from the project name. For example, the project [spice.ai/spiceai/demo](https://spice.ai/spiceai/demo) can connect to `github.com/spiceai/demo` or to `github.com/spiceai/platform`.
- **spicepod.yaml**: The repository needs a `spicepod.yaml` in the project's root directory. The root directory is the repository root unless you set another directory when you connect.

To quickly set up a new repository, use the [spiceai/spice-app-template](https://github.com/spiceai/spice-app-template) as a starting point.

> **Warning**
>
> Make sure to copy the project spicepod.yaml contents from **Build** > **Code** and place it in the project's root directory before linking.

## Connect

1. In the context of the Spice project to connect, navigate to **Settings** > **GitHub**, then find the **Connect Git Repository** section.
2. Click **Connect @\<owner>** and follow the GitHub App installation instructions.

> Ensure that you select all repositories or specifically the repository you intend to connect.

3. Link the repository:
   - If a repository with the same name as the project exists, click **Link Repository**.
   - To use a repository with another name, enter its name under **Connect an existing repository**, then click **Connect repository**.
   - If no repository exists yet, click **Create \<owner>/\<project>**. The owner is the one the **Connect @\<owner>** button shows.
4. Optional: in **Root directory**, enter the directory that contains the project, for example `projects/demo`. Use a path inside the repository, with no leading slash and no `..`. Leave it empty to use the repository root. The portal warns when it finds no `spicepod.yaml` in that directory.

Once connected, the section is titled **Connected Git Repository** and offers a **Production Branch** selector and a **Disconnect** button. To change the directory later, edit **Root directory** in the same settings page and save it.
