Brewless Brewless Docs

Deployments

Deploying from a pipeline

Deploy from GitHub Actions or any other pipeline with a token in BREWLESS_API_TOKEN, without a sign-in in the browser.

On this page

A pipeline cannot approve a sign-in in the browser. It deploys with a pipeline token instead, which the command line client reads from BREWLESS_API_TOKEN, the way Laravel Vapor's client reads VAPOR_API_TOKEN.

Tip

No pipeline of your own? With Deploy on push a push to a branch on GitHub deploys its environment, without a CI pipeline and without a token in your repository.

Making a token

  1. In the console, open Account, the Tokens tab, and go to Pipeline tokens.
  2. Name the token after the pipeline that will hold it, such as GitHub Actions shop, choose the application it deploys (or all applications) and, if you like, when it stops working by itself (after 30, 90 or 365 days). Then choose Create token.
  3. Copy the token. It starts with bl_ and is shown this once: Brewless keeps only a hash of it.

A token can only be made in the console while you are signed in there. A token cannot make another one.

What a token may do

A token for one application may only deploy it: plan and apply its brewless.yml, start a release, follow it to the end or cancel it, and read its releases, logs and post-quantum readiness. It sees no other application. Anything else, such as reading the variables, running a command, changing DNS or removing something, is refused, so a token that leaks from a pipeline cannot do more than deploy. For the rest, use the command line client signed in as yourself.

It acts as you, in the organisation you made it in, and never with more rights than yours. Whatever it changes is in the audit trail under your name, and so are making and revoking it.

It stops working after the period you chose, at once when you revoke it on the Account page, or when you are removed from the organisation. The list there shows which application each token deploys and when it was last used.

A token for all applications has all of your rights, on every application, like the command line client signed in as you; the list marks it. Choose it only when one pipeline deploys several applications. One thing no pipeline token does, also one for all applications: hand out what is in the backups. Restores, their downloads, the Recovery Kit and the recovery key are refused with it; use the command line client signed in as yourself for those. Tokens made before 24 October 2026 are such tokens.

Warning

Keep the token in the secrets of your pipeline, never in the repository. Anyone who holds it can deploy and change the organisation as you.

Using it

Give the pipeline the token as BREWLESS_API_TOKEN. With that variable set, the client uses it instead of a sign-in of the machine, so brewless login is not needed. The organisation still comes from brewless.yml, so the token has to be one of that organisation; when Brewless refuses it, the client says the token was refused and the pipeline fails.

export BREWLESS_API_TOKEN=bl_…
brewless deploy production --no-interaction

With --no-interaction the client asks nothing: domains from brewless.yml that the environment does not answer on yet are only added with --domains. It follows the release until it is live or has failed, and ends with a non-zero exit code when the deploy fails, so the pipeline fails with it.

Stopping the pipeline run stops the release too: the client gets the signal to stop (SIGTERM, which pipelines send when a run is cancelled), cancels the release it started and only then exits. A pipeline that kills the client outright gives it no time for that; cancel the release then with brewless cancel production or in the console, or the next deploy is refused until it is over.

The client needs PHP 8.4 or newer and git, and deploys the commit that is checked out. Install it in the pipeline with composer global require brewless/cli, or download the built file brewless that comes with every release of brewless/cli on GitHub. In a pipeline it does not look for newer versions of itself.

In GitHub Actions the token goes in from the repository's secrets:

.github/workflows/deploy.yml
- run: brewless deploy production --no-interaction
  env:
    BREWLESS_API_TOKEN: ${{ secrets.BREWLESS_API_TOKEN }}

A whole workflow for GitHub Actions

The console makes this workflow for you. Open the application, go to Deploy on push, open the GitHub Actions tab and choose Show the workflow under Or deploy from GitHub Actions. It fills in your environments and the branch each one deploys from (main to production when none has a branch yet), the PHP version of your newest release and the test commands of your framework (for Laravel for Rust: cargo test --locked next to PostgreSQL 18, with PHP set up only for the client that deploys). Make the token next to it makes a pipeline token for that one application, valid for a year, and links to the repository's secrets on GitHub. The example below is the same idea, written out for one environment.

This workflow runs your tests on every push and pull request, and deploys the test environment when a push to main passes them. Put the token in the repository's Settings, Secrets and variables, Actions as BREWLESS_API_TOKEN.

.github/workflows/deploy.yml
name: Test and deploy

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

concurrency:
  group: deploy-${{ github.ref }}
  cancel-in-progress: false

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
      - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
        with:
          php-version: '8.4'
          coverage: none
      - run: composer install --no-interaction --no-progress --prefer-dist
      - run: cp .env.example .env && php artisan key:generate
      - run: php artisan test

  deploy:
    needs: test
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
      - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
        with:
          php-version: '8.4'
          coverage: none
      - run: composer global require brewless/cli --no-interaction --no-progress
      - run: |
          "$(composer global config bin-dir --absolute --quiet)/brewless" deploy test --no-interaction
        env:
          BREWLESS_API_TOKEN: ${{ secrets.BREWLESS_API_TOKEN }}

concurrency keeps two deploys of the same branch from running at once, and cancel-in-progress: false lets a release that started finish.