Deploy from GitHub
Connect a project to a GitHub repository and every push deploys: the production branch to production, every other branch to a preview with its own URL and a pull request comment.
Connect a repository
- 1Give your install’s GitHub App access
Open the project’s Settings → Git. The first time, Install on GitHub takes you to GitHub, where you pick the account and either all repositories or only the ones you choose.
- 2Connect the repository
Back on Settings → Git, the repositories the app can read are listed, most recently pushed first. Click Connect.
- 3Check the production branch and root directory
The production branch is the repository’s default branch unless you change it. Set the root directory if the project lives in a subfolder of a monorepo.
Or start from the repository: New project → Import, name the project, pick the branch and root directory, paste any environment variables, and click Deploy. The production branch builds at once and you land on its build log.
forkrail git repos # what the app can readforkrail git connect shop acme/shop # pushes to the default branch go to productionforkrail git connect shop acme/mono --branch release --root apps/shopforkrail git connect shop acme/shop --create # make the project from the repo and deploy itforkrail git deploy shop # deploy the production branch's newest commit nowforkrail git disconnect shopWhat a push does
- GitHub sends a signed webhook to your dashboard. forkrail fetches that commit’s files and builds them in your builder exactly like
forkrail deploy, with the project’s environment variables and build cache. - The commit gets a status,
forkrail/<project>: pending while it builds, then a link to the deployment or to the failed build’s log. - GitHub is told about the deployment itself, which puts View deployment on the pull request.
- Two pushes to the production branch close together both build. If the older one finishes last, production stays on the newer one.
- Pushes from forks aren’t built.
Branch URLs and pull request comments
Besides each deployment’s own URL, every branch gets an address that follows its newest ready preview: <project>-git-<branch>.<your domain>, with the branch lowercased and anything but letters and digits turned into dashes. feature/Logs becomes shop-git-feature-logs.example.com. A failed, canceled or skipped build leaves it where it was.
Every open pull request gets one comment per connected project, updated as the build goes: building, ready with the branch URL, failed with the step and a link to the log, canceled or skipped.
When a branch is deleted, usually after a merge, its previews are removed with their Lambda versions and its branch URL stops answering. Anything that has been production is kept as a rollback target.
Monorepos
Connect one repository to several projects, each with its own root directory (apps/web, services/api). A push builds all of them. Dependencies install with the workspace’s package manager: the lockfile is found in the folders above the project, up to the repository’s top.
Pushes that don’t deploy
Two vercel.json keys, read from the pushed commit, work as on Vercel:
{ "git": { "deploymentEnabled": { "dependabot/**": false, "wip-*": false } }}{ "ignoreCommand": "[ \"$VERCEL_GIT_COMMIT_REF\" = docs ]"}git.deploymentEnabled: falseturns pushes off entirely; an object turns them off per branch pattern (*within a path segment,**across segments).ignoreCommandruns at the start of a push’s build. Exit 0 skips the build: it’s listed as canceled with the command’s output, and the commit status is a success so required checks don’t block a merge. A build has the commit’s files but not the git history, sogit diff HEAD^ HEADcan’t be used yet.github.autoJobCancelation(on by default) cancels a branch’s older builds when a newer push arrives.github.autoAlias: falsebuilds production deployments without putting them live.
Deploy hooks
A deploy hook is a secret URL that builds a branch’s newest commit when called, for a CMS that publishes or a scheduled job. Create one under Settings → Git → Deploy Hooks or from the CLI. The URL is shown once.
forkrail deploy-hooks create shop "Sanity publish" --branch main # prints the URL onceforkrail deploy-hooks ls shopforkrail deploy-hooks rm shop 3f9a0c1b2d4ecurl -X POST "https://dashboard.example.com/api/deploy-hooks/shop/<secret>"curl -X POST "https://dashboard.example.com/api/deploy-hooks/shop/<secret>?buildCache=false"- A project can have 5 hooks, called 60 times an hour in all; beyond that the answer is
429withretry-after. - Calling a hook again for the same commit cancels the build it started before.
- Only the secret’s SHA-256 is stored. Anyone with the URL can deploy the branch, so treat it like a password.
Limits
- A commit’s files may be up to 256 MB zipped.
- Git submodules and Git LFS files aren’t fetched.
- Builds get the commit’s files, never a GitHub token. The app’s private key is readable only by the control function and your AWS administrators.