Flitzdocs
Integrating Flitz into your workflow

Publish from GitHub Actions

Publish a bundle for every pull request with the Flitz GitHub Actions: install the CLI and the pinned SDK on a runner, publish, and link the build from a pull-request comment.

The Flitz GitHub Actions install the CLI and the SDK your project pins on a GitHub-hosted runner, run flitz publish, and comment on the pull request with a link to the build. Each pull request then carries a preview that your team can open on a real device while they review it.

Prerequisites

  • The project pins an SDK in a committed flitz.yaml (flitz sdk use).
  • The organization API key is stored as a repository secret, for example FLITZ_APIKEY (Settings → Secrets and variables → Actions). Create the key on the Settings page of the portal or with flitz apikey create.
  • A supported runner: Linux x64 (ubuntu-latest) or Apple-silicon macOS (macos-latest). Every other runner fails on the first step.

Publish every pull request

.github/workflows/flitz-preview.yml
name: Flitz preview

on: pull_request

concurrency:
  group: flitz-preview-${{ github.event.pull_request.number }}
  cancel-in-progress: true

permissions:
  contents: read
  pull-requests: write

jobs:
  preview:
    runs-on: ubuntu-latest
    # Pull requests from forks get no secrets.
    if: github.event.pull_request.head.repo.full_name == github.repository
    steps:
      - uses: actions/checkout@v7
      - uses: leancodepl/flitz-actions@main
        with:
          api-key: ${{ secrets.FLITZ_APIKEY }}
  • pull-requests: write lets the action post its comment. On a push or a manual run it publishes and posts nothing.
  • @main follows the newest version of the actions. To choose when you take updates, pin a commit SHA instead.

The action:

  1. Installs the newest CLI and the SDK that flitz.yaml pins, and caches the SDK and your pub dependencies between runs.
  2. Runs flitz publish --yes --json in the folder that holds flitz.yaml. --yes downloads the SDK on a cold cache and creates the app when flitz.yaml names one your organization does not have yet.
  3. Labels the publish in the publish history: PR #<number>: <title> as its name, pr-<number>-<short sha> as its version name, and the pull request, the commit, and the run as its comment. Values over the CLI's limits are trimmed, with a warning.
  4. Adds the links to the run's summary page, and comments on the pull request with a link to the landing page. The deeplink, the bundle link, the publish ID, and the commit are in a collapsed Details block. Each run replaces the action's previous comment, so the pull request shows one current preview.

The publish lands on the track of the pull request's branch, or of the pushed branch on a push. The app is the one flitz.yaml names with app:, or your pubspec name:. The action has no input for the app key or the track; set them in flitz.yaml when the defaults do not fit.

Inputs

InputDefaultPurpose
api-keyrequiredThe organization API key, from a repository secret.
flitz-pathflitz.yamlThe project's flitz.yaml, relative to the repository root. The CLI runs in its folder, which suits a monorepo.
appthe folder of flitz.yamlThe Flutter project folder, relative to the repository root, as --dir.
targetlib/main.dartThe Dart entry point, as --target, relative to the project folder.
dart-define—Compile-time constants, one KEY=VALUE per line. Commas inside a value are kept.
dart-define-from-file—.json or .env files of constants, one path per line, relative to the repository root.
schemaflitzThe URL scheme of the links, as --schema. Set it to the scheme your host registers, or set schema: in flitz.yaml.
name, version-name, commentthe pull request's detailsThe publish labels, as above.
cli-versionlatestA CLI version, such as 0.5.0.
cache, pub-cachetrueWhether to cache the SDK and the pub dependencies.
pr-comment-header📱 Flitz preview buildThe comment's heading.
pr-comment-messageOpen it with a Flitz-enabled loader build.Markdown below the landing-page link, for example which build of your app opens it.
pr-comment-keydefaultTells comments apart when one pull request publishes several apps.

The action's outputs include page-url, deeplink, bundle-url, and id — the fields of the publish result — and comment-url.

For a monorepo app with its own flitz.yaml, a flavor entry point, and a compile-time constant:

- uses: leancodepl/flitz-actions@main
  with:
    api-key: ${{ secrets.FLITZ_APIKEY }}
    flitz-path: mobile/flitz.yaml
    target: lib/main_staging.dart
    dart-define: |
      API_URL=https://staging.example.com
    pr-comment-message: Open it in the staging build of the app.

Compose the steps yourself

The combined action is three smaller ones, which you can use separately — for example, to run your tests before anything is published:

- uses: leancodepl/flitz-actions/install@main
  with:
    api-key: ${{ secrets.FLITZ_APIKEY }}
- run: flutter test
- id: flitz
  uses: leancodepl/flitz-actions/publish@main
  with:
    api-key: ${{ secrets.FLITZ_APIKEY }}
- uses: leancodepl/flitz-actions/pr-comment@main
  with:
    page-url: ${{ steps.flitz.outputs.page-url }}
    deeplink: ${{ steps.flitz.outputs.deeplink }}
    bundle-url: ${{ steps.flitz.outputs.bundle-url }}
    id: ${{ steps.flitz.outputs.id }}
ActionWhat it does
leancodepl/flitz-actions/installInstalls the CLI and the pinned SDK, puts the SDK's flutter and dart first on PATH, and restores the pub cache.
leancodepl/flitz-actions/install-cliInstalls only the CLI. It needs no API key.
leancodepl/flitz-actions/install-sdkInstalls only an SDK, the one flitz.yaml pins by default. Needs the CLI.
leancodepl/flitz-actions/publishRuns flitz publish and sets the outputs. Needs the CLI.
leancodepl/flitz-actions/pr-commentPosts or replaces the pull-request comment. Needs no Flitz tools.

A flitz command you run in your own step needs the key in its environment, FLITZ_APIKEY: ${{ secrets.FLITZ_APIKEY }}: no action exports it. The actions mask the key in the log and pass it only to the steps that run flitz.

Troubleshooting

You seeWhat it meansRemedy
A failure naming the runner's OS and architectureThe runner is not Linux x64 or Apple-silicon macOS.Use ubuntu-latest or macos-latest.
A failure naming the api-key inputThe secret is empty, for example in a run from a fork.Store the key as a repository secret, and skip runs from forks as above.
A failure naming pull-requests: writeThe job cannot comment, or the run comes from a fork.Add the permission to the workflow.
the Flitz credential was rejected (exit 3)The key was rotated or revoked.Update the secret with the current key. See flitz apikey.
your organization's Flitz license is not active (exit 3)The organization's license lapsed.Ask your organization's Owner to open Billing in the portal.

Everything else fails as flitz publish does on your own machine, with the same message and exit code; see CLI troubleshooting and Exit codes.

On this page