# Deploy with a GitHub App

> Deploy public and private repositories from a list, on every push, with Vantuly's GitHub App or an app of your own.

Source: https://vantuly.com/docs/guides/github-app

A GitHub App gives Vantuly access to the repositories you choose, in your personal account or an organization. Pick a repository from a list, and every push to its branch deploys. There are no deploy keys or webhooks to add by hand.

There are two ways to do it, both under **Settings → Team → Git**: install **Vantuly's GitHub App**, or create **your own GitHub App**.

Need only one repository, or can't install an app? Use a [deploy key](/docs/guides/git-deploy/) instead.

## Which app to use

**Use Vantuly's GitHub App** to deploy repositories, public or private, on every push. It is enough for most sites: install it, pick repositories, and you're done.

**Create your own GitHub App** when you need any of these:

- [Pull request previews](#pull-request-previews): a copy of the site for each open pull request.
- [GitHub Actions runners](#github-actions-runners): your organization's CI jobs running on your servers.
- An app that belongs to your GitHub account or organization, with its own name, logo and settings.

| | Vantuly's GitHub App | Your own GitHub App |
|---|---|---|
| Setup | Install it and pick repositories | Create the app on GitHub, then install it |
| Public and private repositories, deploy on every push | Yes | Yes |
| Private submodules on GitHub | Yes | Yes |
| Pull request previews | No | Yes |
| GitHub Actions runners | No | Yes, for organizations |
| Who controls the app | Vantuly | You |

You can use both: each site picks one account to deploy from.

## Use Vantuly's GitHub App

1. Go to **Settings → Team → Git** and click **Install the GitHub App**.
2. On GitHub, choose your personal account or an organization, then **All repositories** or **Only select repositories**, and click **Install**.
3. GitHub sends you back to Vantuly, and the account appears under **Vantuly's GitHub App**. Click **Add another GitHub account** to connect more.

Then [deploy a repository](#deploy-a-repository) and choose that account. Vantuly adds a webhook to the repository, so pushes to the branch deploy on their own.

To stop, click **Disconnect** on the account. Sites keep their code, but new deploys stop. To remove the app from GitHub too, open your account's or organization's **Settings → Applications** on GitHub and uninstall it there.

You need to be an owner or admin of your Vantuly team to connect an account.

## Use your own GitHub App

Your own app lives in your GitHub account or organization, and your team uses it. Panel administrators can also share an app with every team (see [System wide](#system-wide)).

Under **Settings → Team → Git**, open **Your own GitHub App**. It's closed by default, as most sites don't need it, and opens on its own once your team has an app.

## What your own app can do

| Permission or event | Access | Why |
|---|---|---|
| Contents | Read | Clone the repository |
| Metadata | Read | List repositories and branches |
| Administration | Read | Reported on the app, as in Coolify |
| Email addresses | Read | Reported on the app, as in Coolify |
| Push event | | Deploy when you push |
| Pull requests | Read and write | Only with **Pull request previews**: comment on pull requests |
| Pull request event | | Only with **Pull request previews** |
| Self-hosted runners, Actions, Workflow job event | | Only with **GitHub Actions runners** |

The app can't change code in your repositories. Each deployment clones with a token GitHub issues for your installation, valid for an hour. It can read every repository the app is installed on, which is what lets it read private submodules. The server keeps no GitHub credentials: the token goes only to a git command the server runs as root for that one fetch, and isn't written to disk. Your site's own code, including previews of pull requests, never sees it.

## Create your own app

You need to be an owner or admin of your Vantuly team. For an organization app, you also need to be allowed to manage GitHub Apps in that organization.

1. Go to **Settings → Team → Git**, open **Your own GitHub App** and click **New GitHub App**.
2. Enter a **Name**. GitHub needs a name no other app uses, like `acme-vantuly`.
3. Enter the **Organization** that should own the app, or leave it empty for your personal account.
4. Under **Use this app for**, choose what you need. Deploying repositories is always included.
   - **Pull request previews** adds the pull request permission and event.
   - **GitHub Actions runners** adds the runner permissions and event. It needs an organization.
5. Click **Continue**, then **Register with GitHub**. GitHub may ask you to confirm your password or passkey.
6. Check that the button names the right owner, then click **Create GitHub App**.

## Choose the repositories

GitHub sends you straight to the install page after you create the app.

1. Choose **All repositories** or **Only select repositories**. Selecting only what you deploy is safer.
2. Click **Install**.

Back in Vantuly, the app shows **Connected**. Click **Test connection** to see how many repositories it can read, and to refresh the app's permissions.

To change the list later, click **Repositories** on the app, change it on GitHub, and save.

:::note
GitHub says an app with selected repositories also has read access to public ones, but only the repositories you select appear in the list. To deploy a public repository through the app, select it too.
:::

## Deploy a repository

**Docker sites**

1. Click **New site**, choose **Docker** and then **Git Repository (with GitHub App)**.
2. Pick the server.
3. Choose the GitHub account (Vantuly's app or your own) and a repository. The list marks each one as public or private.
4. Click **Check repository**. Vantuly reads it on that server, finds the Dockerfile or compose file, and suggests the build settings.
5. Set the branch and the build settings, add the domain, and create the site.

**Laravel, PHP, static, Node.js, Astro, EmDash and Python sites**

1. Open the site's **Deployments** tab and click **Use a GitHub App instead**.
2. Choose the GitHub account (Vantuly's app or your own), a repository and the branch, then click **Connect repository**.

Pushes to the chosen branch now deploy on their own. You can also click **Deploy now** at any time.

### Submodules

Submodules on the same host as the repository are cloned with the same token, so private ones work too, including submodules inside submodules (up to five levels). A submodule on another host, or an SSH address, is skipped with a line in the deployment log and the deploy goes on.

## Permissions

Open **Permissions** on the app to see what GitHub reports: contents, metadata, administration, pull requests, runners, actions and webhook events. If **Pull request previews** or **GitHub Actions runners** is missing something, the section says what, with an **Update on GitHub** link. Accept the new permissions on GitHub, then click **Test connection**.

## Pull request previews

A preview is a copy of your site that runs the code of an open pull request, on its own address. It is a separate site on the same server, so it has its own user, files, environment and logs.

1. Open the site and go to its **Previews** tab. It appears when the site deploys through your own GitHub App and that app's **Pull request previews** option is on.
2. Switch **Preview deployments** on. If GitHub still needs a permission, the tab says which.
3. Open a pull request, or click **Load pull requests** and **Deploy preview**.

Each pull request gets its own address from the **URL template**. The default is `{{pr_id}}.{{domain}}`, so pull request 12 of `app.example.com` becomes `12.app.example.com`. `{{random}}` adds a short random part. Point a wildcard DNS record at the server (`*.app.example.com`) so previews resolve. A site that only has a free address gets a random free address for each preview instead.

Each push to the pull request redeploys its preview. Closing the pull request deletes the preview and its comment. Pushes to the base branch don't redeploy previews.

On a private repository, the app comments on the pull request with the preview's status and links: building, ready, failed. Public repositories get no comments.

**Who can start a preview.** By default only pull requests from branches in the same repository do (**Repository members only**). Pull requests from forks need **Public (fork PRs allowed)**. A fork preview runs code from someone outside your repository, so it gets none of your site's environment variables, and Docker previews also leave out build arguments, registry logins and replaced values. Turn it on only for repositories where you accept that.

Previews of your own branches copy the site's environment, including database settings. Change them on the preview's **Environment** tab if previews must not use production data.

Each preview counts toward your site limit. Use **Redeploy**, **Rebuild** (without the build cache, Docker sites), **Stop** or **Delete** on each row.

## GitHub Actions runners

Run your organization's GitHub Actions jobs on your own servers. This is in beta. The app needs to belong to an organization and to have been created with **GitHub Actions runners** ticked.

:::caution
A runner runs whatever a workflow says, with the server's network around it. Use it only for repositories you trust. Pull request jobs run on the server too, so they are off by default.
:::

1. Open the server and go to its **GitHub runners** tab. Changing its settings needs an owner or admin of your Vantuly team.
2. Switch **Run GitHub Actions jobs on this server** on and choose the GitHub App.
3. Enter one or more **Labels**, like `vantuly`. Every runner also has `self-hosted` and `linux`.
4. Click **Save**. If GitHub still needs a permission, the tab says which. Accept it on GitHub, then click **Test connection** under **Settings → Team → Git**.

Then ask for the runner in a workflow:

```yaml
jobs:
  build:
    runs-on: [self-hosted, linux, vantuly]
```

When GitHub queues a job that asks for one of your labels, Vantuly starts a runner container for that one job on the least busy server, and removes it when the job ends. The **Jobs** list on the tab shows each job and lets you cancel one. Cancelling stops Vantuly from running it, but the workflow run stays queued or running on GitHub until you cancel it there too, and a later runner with the same labels can pick it up.

| Setting | What it does |
|---|---|
| **Parallel runners** | How many jobs run at once on this server (1 to 32). |
| **Docker in jobs** | None by default. **Docker in Docker** runs a privileged helper and needs you to confirm your password. **Sysbox** needs the Sysbox runtime on the server. Jobs reach the helper's Docker at `DOCKER_HOST`, never the server's. |
| **Runner image** | The image jobs run in. It has no Docker command, so jobs that call `docker` need your own image. |
| **CPU limit**, **Memory limit** | Caps for each runner. |
| **Queue wait**, **Idle**, **Job limit** | How long a job may wait for a server, how long an unused runner lives, and how long one job may run. |
| **Allow pull request jobs** | Off by default. When off, a check inside the runner stops jobs started by pull requests before any of their steps run, including `if: always()` steps. |
| **Dedicated server** | The server builds no Docker sites. |

The server's own Docker socket is never given to a job. The runner's registration is a secret that is stored encrypted and removed from the server as soon as the runner starts. An app can't be deleted while a server uses it for runners: turn them off first.

## System wide

Panel administrators (`APP_ADMIN_EMAILS`) can click **Make system wide** on an app, or tick **System wide** when creating it. Every team on the panel can then deploy the repositories the app reads. Other teams see the app, can choose it and can test it, but can't change it, delete it, or see its webhook or secrets. They also can't see which other teams use it. The app can't be deleted while any team's site deploys through it.

Only turn it on for an app whose repositories every team may deploy.

## Create the app by hand

Use this if you want full control over the app on GitHub.

1. Go to **Settings → Team → Git**, open **Your own GitHub App**, click **New GitHub App**, enter the name and click **Continue**. Then click **Continue manually**.
2. On GitHub, open **Developer settings → GitHub Apps → New GitHub App**. For an organization, open the organization's settings first.
3. Fill in the app:
   - **Homepage URL:** your Vantuly address.
   - **Webhook URL** and **Secret:** copy both from Vantuly.
   - **Repository permissions:** Contents, Metadata, Administration, all read-only; Pull requests read and write if you want previews.
   - **Account permissions:** Email addresses, read-only.
   - **Subscribe to events:** Push, and Pull request for previews.
   - **Where can this GitHub App be installed?** Only on this account.
4. Click **Create GitHub App**, copy the **App ID**, then generate a private key under **Private keys**. GitHub downloads a `.pem` file.
5. Open **Install App** and install it on your account or organization. The number after `/installations/` in the page's address is the **Installation ID**.
6. Back in Vantuly, enter the **App ID** and **Installation ID**, paste the whole `.pem` file into **Private key**, and click **Connect**.

Keep the webhook secret and the private key to yourself. Vantuly stores them encrypted and never shows them again.

## Delete an app

Click **Delete** on the app. Vantuly refuses while sites deploy through it and names them, so connect those sites another way first.

This removes the app from Vantuly only. It stays registered on GitHub, so remove it from the app's settings there as well.

## Troubleshooting

**A repository is missing from the list.** Give the app access to it on GitHub. For your own app, click **Repositories** on the app. For Vantuly's app, open **Settings → Applications** on GitHub (your account's or the organization's) and configure the Vantuly app there.

**Pushes don't deploy, but Deploy now works.** Open the app's settings on GitHub and check **Advanced → Recent Deliveries**. GitHub must be able to reach your Vantuly address. If your panel isn't public, set `APP_GITHUB_WEBHOOK_URL` to a public address that forwards to it, such as a tunnel.

**A deployment says the app can't read the repository.** The app lost access, or it was uninstalled. Click **Repositories** on the app to give it access again.

**Previews don't start.** Open the app's **Permissions** section. An app made before previews existed needs the Pull requests permission and the Pull request event added on GitHub. Accept the change, then click **Test connection**.

**A runner job never starts.** Check that the workflow's `runs-on` lists `self-hosted`, `linux` and one of the server's labels, that the server is online, and that the app's **Permissions** section shows nothing missing for runners. The **Jobs** list on the server's GitHub runners tab shows what Vantuly saw.

**A submodule was skipped.** Check the deployment log. Submodules on another host, and SSH addresses, can't be read with the app's token.

**You use a Git host other than GitHub.** Use a [deploy key](/docs/guides/git-deploy/).
