HF PanelDocsv1.0.0

Deploys & previews

Deploy a Git repository's live branch to your website on every push, and get a preview website for every other branch.

Deploys & previews turns a Git repository into automatic deploys. Its live branch (main by default) deploys to one of your websites whenever it gets a new commit, and every other branch you push gets its own preview website at <branch>.preview.yourdomain.com. Each copy runs your deploy script, and its output is kept as the build log.

Where: Control Panel › Software › Git › Deploys & previews (on a repository's row, or in an open repository)

Set it up

  1. On the Git page, click Deploys & previews on the repository's row.
  2. Fill in Settings and click Save:
Field What it does
Live website the website the live branch deploys to (into its folder). None = no live deploys. Previews are made below this website, so it is needed for them too.
Live branch the branch that deploys live; main when empty
Deploy script shell commands run as your account in the copied folder after each deploy, for example composer install --no-dev or npm ci && npm run build. Up to 4,000 characters, 15 minutes at most. HF_BRANCH, HF_COMMIT and HF_PREVIEW (1 for a preview, 0 live) are set.
A preview website for each pushed branch previews on or off
Branches which branches get a preview, separated by commas; feature/* matches every branch starting with feature/. Empty = every branch except the live one.
Keep for (days, 0 = until the branch is deleted) a preview with no new push for this many days is removed (0–365)

Pushes are picked up within 5 minutes. Click Check for pushes now to deploy straight away. A cloned repository is fetched from its remote first; for a repository on this server, its own branches are used.

The live deploy

The Live deploy card shows the live branch, the website, the status (Ready or Failed), the commit, when it was last deployed and when the repository was last checked, with the Build log. Deploy now deploys the live branch again even when it has no new commit.

A live deploy copies the branch's files (never .git) over the website's folder; files the branch doesn't have, such as uploads, are kept. Then the deploy script runs. If the script fails the files stay copied and the status is Failed — read the build log.

Previews

Each branch gets a website named after the branch: lower case, every other character a -, up to 30 characters. feature/New_Menu becomes feature-new-menu.preview.yourdomain.com. Its folder is ~/web/previews/yourdomain.com/feature-new-menu, and it holds exactly the branch's files.

Column What it shows
Branch the branch
Address the preview's link (point its DNS here and get free SSL on the SSL/TLS page)
Status Building, Ready, Failed or Expired, with the Build log
Last deploy the commit and when it was built
  • Rebuild builds the preview again from the branch's newest commit (an expired one comes back).
  • Remove removes the preview website now; it comes back with the branch's next push.
  • When a branch is deleted, its preview website is removed at the next check.

The card's title shows how many previews you have and your plan's limit, for example 2 / 3. When the limit is reached, new branches wait and a note says so. Deleting the repository removes its preview websites; the live website is left as it is.

Note: the deploy script runs as your account, like a cron job. Keep secrets out of the repository: put them in files the script reads, or in the app's own settings.