Skip to content

Git and CI

Publish from Git: connect a GitHub repository, push straight to Perafly, or publish from your CI. The production branch goes live; other branches get preview addresses.

On this page

Three ways

WayHow it works
GitHub AppInstall the Perafly GitHub App on your account or organization and connect a repository to the project. Pushes and pull requests arrive as signed webhooks; Perafly fetches that commit's files and publishes them, then writes the result back as a commit status and a pull request comment.
Direct pushEvery project has its own Git address, https://git.perafly.com/<project>.git. Push to it from any Git host, no GitHub needed.
CIRun perafly publish in your CI job with PERAFLY_TOKEN.

In every case only committed content is published, the files go through the same filters as any publish, the build runs on the hosting provider and the result is a version. Git needs a project with an account.

Branches and previews

EventResult
Push to the production branchWith automatic production deploys on (default): published to live. If the project publishes manually, the version is only made ready. Off: a preview.
Push to another branchWith automatic previews on (default): a preview at https://<project>--br-<branch>.perafly.app. Off: no build.
Branch deletedIts branch address goes away.
Pull request from the same repositoryThe push is already built; when the build finishes, Perafly comments on the pull request.
Pull request from a forkWaits (awaiting_approval) until a member approves; then a preview at <project>--br-pr-<number>. Closing the pull request removes the address.

The branch part of the address is lower case, with every character that isn't a letter or digit turned into -. The production branch is main unless you change it. The number of active branch previews per project comes from your plan; past it, the branch updated longest ago loses its address (its version stays).

Turning on automatic production deploys lets anyone who can push to the branch change the live site, even if they aren't on your Perafly team, so it needs permission to promote versions. A fork's code builds with the project's environment variables, secrets included: read the pull request before approving it.

Connect GitHub

  1. Open the project's Git tab in the dashboard and install the Perafly GitHub App. You can give it access to selected repositories only.
  2. Pick the repository. Or from a terminal, once the app is installed:
Terminal
perafly git set --repository acme/site
perafly git set --production-branch main --auto-previews off
perafly git                       # connection, branches, push address and the last 5 builds
perafly git builds --status awaiting_approval
perafly git approve gbd_…         # build a fork's pull request (asks to confirm)
perafly branches                  # branch addresses and the version each serves
perafly git disconnect            # no new builds; versions and branch addresses stay

The app asks GitHub for read access to contents and metadata, and write access to pull requests (for the comment) and commit statuses. If the repository appears in more than one installation, add --installation <id>. Agent credentials can't change these settings.

Direct push

perafly git remote adds the project's push address to the repository as a remote named perafly (it never touches origin) and sets the CLI as Git's credential helper for that address only. Your key is never written into the address or Git's configuration.

Terminal
perafly git remote
git push perafly HEAD:main              # production branch: live
git push perafly HEAD:feature-login     # other branches: https://<project>--br-feature-login.perafly.app
  • The push needs publish.write. The password is an API key: the credential helper gives your sign-in or PERAFLY_TOKEN.
  • Only branches are published; tags are accepted but not published. Pulling from the address is closed.
  • Pushing the production branch with an agent sign-in waits for approval like any change to live.
  • perafly git remote --name <name> uses another remote name.

Publish from CI

perafly publish finds the branch and commit in GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI and sends them with the publish. Without --target, the project's branch rule decides: the production branch goes live, other branches get branch previews. --branch and --commit work anywhere and win over what CI reports.

GitHub Actions

.github/workflows/perafly.yml
# .github/workflows/perafly.yml
name: Perafly
on: [push]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm ci && npm run build
      # PERAFLY_TOKEN: a repository secret holding an API key (pfa_…).
      # The project comes from the committed .perafly/project.json (perafly link) or PERAFLY_PROJECT.
      - run: npx perafly publish ./dist
        env:
          PERAFLY_TOKEN: ${{ secrets.PERAFLY_TOKEN }}

Create the key with perafly api-keys create ci (or in team Settings) and store it as the PERAFLY_TOKEN secret. In CI the CLI writes JSON and never asks questions; that doesn't mean --yes.

Build settings

Build commands and the folder to build in (for one project in a larger repository) go in perafly.jsonc: build.rootDirectory, installCommand, buildCommand, outputDirectory. Whatever you leave out is detected by the hosting provider. How many builds a team runs at once comes from its plan; a newer push to the same branch replaces a build that hasn't started.

Disconnecting stops new builds; published versions stay. Rolling back moves live to an older version; it doesn't change your repository.