Appearance
Branch previews
A branch preview shows the code of one Git branch of your frontend, at its own address, with the site's saved preview content. Developers can try a change before it reaches main. Live and the site's main preview do not change.
What a branch push does
With the repository connected, the workflows from foliwake create do this:
| Event | Workflow | What happens on the server |
|---|---|---|
Push to a branch other than main | branch-preview.yml | That commit becomes the branch's code; its branch preview shows it |
| Delete the branch | branch-preview.yml | The branch preview stops being served |
Push to main | production.yml | The code is prepared and every page rebuilt in the site's preview; see roll out frontend code |
| Pull request or any push | frontend-checks.yml | Tests only; no secrets, no server |
The server checks that the commit is still the tip of the branch, and refuses a run older than one it already handled. Pushes from forks never run the deploy jobs.
All branch previews share the saved preview content. They select different code. They are not content branches. Rebuilding a branch preview's pages against its own code is planned.
Addresses
A branch gets a host name inside the site's preview domain:
text
<branch>--<site>--<org>.<preview domain> canonical
<branch>--<site>.<preview domain> alias, also servedFor example, branch berry-demo of site docs-site in the default organisation: berry-demo--docs-site--default.preview.example.com, also reachable as berry-demo--docs-site.preview.example.com.
<branch> is a readable form of the branch name: lower case, other characters replaced by -, cut to at most 40 characters. feature/hero becomes feature-hero. The first branch to get a readable name keeps it. A branch that cannot use one uses a form with a short hash instead, such as feature-hero-1a2b3c4d. That happens when another branch already has the name, when the name is reserved (such as www or admin), or when it is exactly two characters long.
A host name is one DNS label of at most 63 characters. When <branch>--<site>--<org> does not fit, even with the hashed form, the branch gets only <branch>--<site>, without the organisation. A site with its own branch host domain also uses the form without the organisation. foliwake branch list prints each branch's addresses.
A page on a branch host answers with an X-Publish-Expect: sr_…@cd_… header. Publishing with that value is refused unless that code is the code going live. See preview and publish.
Connect the repository
The workflows do nothing until the repository is connected. "Frontend checks" runs from the start; it needs no secrets.
- Push the repository to GitHub.
- Ask the operator of your Foliwake server to add the repository to a site (a private repository also needs its read token stored on the server as
<SITE>__CODE_TOKEN). They give you the site ID. - Create a CI key of the site:
foliwake account keys create --site <site> --server <server>. - In the GitHub repository settings, add:
- Environments:
branch-previewsandproduction(limited to themainbranch), each with the secretFOLIWAKE_TOKEN= the CI key. - Variables:
FOLIWAKE_SERVER(the server's address);FOLIWAKE_SITE_ID(the site ID);BRANCH_PREVIEWS_ENABLED=trueto turn on branch previews;FRONTEND_PRODUCTION_DEPLOY_ENABLED=trueto turn onmain→ preview. OptionallyFOLIWAKE_PREVIEW_URLandFOLIWAKE_PRODUCTION_URL, shown as links in GitHub. - Branch protection for
main: require thefrontend-checksstatus check.
- Environments:
Each variable turns on one workflow, so you can start with branch previews and add production later.
The workflows run the open CLI with npx at the exact version pinned in the project's package.json (npx @foliwake/cli@<version> code deploy, branch update, branch delete). The CI key can deploy code and update or delete branch previews of this one site; it cannot publish pages, release a preview or roll back. Projects created before this form (by create-foliwake 0.7.0 or older) have workflows that deploy over SSH to a forced command; replace them with the current starter's .github/workflows/.
What the operator provides
- A site, with this repository as its frontend source.
- A way to make a CI key of the site (
foliwake account keys create), with an account that may. - A preview domain for branch hosts, with wildcard DNS for it and a gateway that routes those names to Foliwake with HTTPS. A wildcard certificate needs the ACME DNS challenge.
- Access protection for preview and branch hosts, when they are reachable from the internet.
The Docker package does not set up branch previews yet. Its first-run wizard configures exact host names only.
Branch commands
bash
foliwake branch list # branches, their code and addresses
foliwake branch history <branch> # what the branch showed over time
foliwake branch bootstrap # once per site: start the default branch from live code
foliwake branch update <branch> --rev <branch> --latest-selection
foliwake branch delete <branch> --latest-selectionA branch write names the selection it expects: --expect sel_… (from branch list --json), --expect none for a branch without a preview, --latest-selection to read it once now, or --sequence <n> (what the deployment commands pass: the workflow run, so an older run never overwrites a newer one).
branch list and branch history can run against a server (--server, see accounts and sign-in). bootstrap, update and delete run with the server's local configuration; the workflows call them through the deployment commands. Branch previews need the admin or developer role.
