Featurevisor

CI/CD guides

GitHub Actions (GHA)

Set up continuous integration and deployment of your Featurevisor project with GitHub Actions.

Find more info about GitHub Actions here.

Creating a new project

This guide assumes you have created a new Featurevisor project using the CLI:

Command
$ mkdir my-featurevisor-project && cd my-featurevisor-project
$ npx @featurevisor/cli init
$ npm install

Add a .nvmrc file containing the Node.js version used by the project:

.nvmrc
24

Workflows

We will be covering two workflows for our set up with GitHub Actions.

Checks

This workflow runs for pull requests and for pushes to branches other than main or master.

This will help identify any issues with your Pull Requests early before you merge them to your main branch.

.github/workflows/checks.yml
name: Checks
on:
pull_request:
push:
branches-ignore:
- main
- master
permissions:
contents: read
jobs:
ci:
name: Checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npx featurevisor lint
- name: Test specs
run: npx featurevisor test
- name: Build
run: npx featurevisor build

Publish

This workflow is intended to be run on every push to your main (or master) branch, and is supposed to handle uploading of your generated datafiles as well:

.github/workflows/publish.yml
name: Publish
on:
push:
branches:
- main
- master
permissions:
contents: write
jobs:
ci:
name: Publish
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npx featurevisor lint
- name: Test specs
run: npx featurevisor test
- name: Build
run: npx featurevisor build
- name: Upload datafiles
run: echo "Uploading..."
# Update "datafiles" directory content based on your CDN set up
- name: Git configs
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Push back to origin
run: |
git add .featurevisor/*
git commit -m "[skip ci] Revision $(cat .featurevisor/REVISION)"
git push

After generating new datafiles and uploading them, the workflow will also take care of pushing the Featurevisor state files back to the repository, so that future builds will be built on top of latest state.

The checks workflow only needs read access. The publish workflow declares write access because it commits the updated state files. Your organization policy must allow workflows to request this permission.

If you want an example of an actual uploading step, see Cloudflare Pages integration guide.

Sequential builds

It is possible you might want to run the publish workflow sequentially for every merged Pull Requests, in case multiple Pull Requests are merged in quick succession.

Queue

You can consider using softprops/turnstyle GitHub Action to run publish workflow of all your merged Pull Requests sequentially.

Branch protection rules

Next to it, you can also make it stricter by requiring all Pull Request authors to have their branches up to date from latest main branch before merging:

Previous
Groups