# GitHub

Connect a repository once: every push deploys, every pull request gets its own URL.

Connect a repository once, and you stop deploying by hand. Every push to the branch you chose builds and goes live on your domains. Every pull request builds too, on an address of its own, so a change can be looked at before it is merged — and the address is posted back to the pull request.

## Connecting

1.  In the console, open your project → **Settings** → **GitHub**.
2.  Choose **Connect GitHub**. GitHub asks which repositories to grant — pick only the ones you want deployed. You can change that list later, on GitHub, without coming back here.
3.  Pick a repository, confirm the branch that serves production, and decide whether pull requests get previews.

Private repositories work: each build clones with a token that nesly asks GitHub for at build time and that expires within the hour. nesly never asks for your GitHub password and never holds a personal access token.

## What happens on each event

| On GitHub | Here | What that means |
| --- | --- | --- |
| Push to the connected branch | Production deploy | Your domains serve the new build once it is ready. The previous deployment stays reachable at its own URL. |
| Pull request opened or updated | Preview deploy | A build of that branch on its own address, commented on the pull request. |
| Pull request closed or merged | Preview stopped | The preview URL stops answering and the workload is removed. |
| Push to any other branch | Nothing | Only the connected branch deploys to production. |
| Pull request from a fork | Nothing | A fork's code is written by someone with no write access to the repository. Building it would run that code with your environment variables, under your name. |
| Commit or PR title contains \[skip ci\] | Nothing | Also \[ci skip\], \[no ci\], \[skip actions\], \[skip deploy\] (and the swapped forms). The token may sit on any line of the commit message. |

## Previews

A preview is a full deployment of the pull request's branch, built with the same commands production is built with. It gets its own permanent address and it never takes over your project's domains, however green it is.

A preview URL is public, so a preview never gets your production database. The first preview of a project with a Postgres, MySQL, MS SQL, MongoDB, Valkey or bucket addon gets a database of its own, empty, and every later preview of the project uses that one; it goes when the addon or the project does. Your own variables carry over. To point previews somewhere else, set`nesly env set DATABASE_URL=... --env preview`; to use production's on purpose,`nesly env share DATABASE_URL --with preview`.

A preview address is public by default — it is meant to be pasted into a pull request and opened by whoever is reviewing. When the work is not for everyone, close it with`nesly protect preview set --password ...`: the address then asks for that password before it serves anything. Your published site is never affected. For CI, which has no browser, `nesly protect preview token` mints a token to send as the`X-Nesly-Preview-Bypass` header.

The pull request carries one comment, edited on every push rather than repeated, and the commit carries a status you can see from the pull request's checks. When the pull request is closed or merged, the preview is taken down.

## What nesly asks GitHub for

<table class="w-full border-collapse text-sm"><tbody><tr class="border-b border-neutral-200 align-top dark:border-neutral-800"><td class="py-2 pr-6 whitespace-nowrap text-neutral-900 dark:text-neutral-100">Contents</td><td class="py-2 pr-6 whitespace-nowrap">Read</td><td class="py-2">Clone the repository to build it.</td></tr><tr class="border-b border-neutral-200 align-top dark:border-neutral-800"><td class="py-2 pr-6 whitespace-nowrap text-neutral-900 dark:text-neutral-100">Metadata</td><td class="py-2 pr-6 whitespace-nowrap">Read</td><td class="py-2">List the repositories you granted, so you can pick one.</td></tr><tr class="border-b border-neutral-200 align-top dark:border-neutral-800"><td class="py-2 pr-6 whitespace-nowrap text-neutral-900 dark:text-neutral-100">Commit statuses</td><td class="py-2 pr-6 whitespace-nowrap">Write</td><td class="py-2">The green check next to your commit.</td></tr><tr class="border-b border-neutral-200 align-top dark:border-neutral-800"><td class="py-2 pr-6 whitespace-nowrap text-neutral-900 dark:text-neutral-100">Pull requests</td><td class="py-2 pr-6 whitespace-nowrap">Write</td><td class="py-2">One comment with the preview URL, updated in place.</td></tr></tbody></table>

That is the whole list. No access to your organisation's members, your other repositories, your Actions secrets, or anything you did not grant. Everything is revocable from your own GitHub settings, and revoking it there unlinks the projects here.

## From the terminal

Deployments made by a push look like any other deployment, and say which pull request they belong to:

```
nesly ls
nesly inspect dep_...      # Preview of: pull request #7
nesly logs                 # the build output of the last deployment
```

How the build itself is configured — the directory, the commands, the output — is on the [builds](/docs/builds/) page, and is the same for pushes, pull requests and `nesly deploy`.

## When a push does not deploy

-   **The branch is not the connected one.** Only the branch you chose deploys to production; change it in the console.
-   **The pull request comes from a fork.** Deliberate — see the table above.
-   **The repository was removed from the installation.** Add it again on GitHub; the project reconnects on the next push.
-   GitHub keeps a delivery log for the app under your repository's settings. Every delivery gets an answer saying what was done and, when nothing was, why.

---
Canonical: https://nesly.net/docs/git/
Markdown: Accept: text/markdown on the HTML URL, or replace the trailing slash with .md
