# Push to a branch. It goes live.

Push to a branch on GitHub and its environment goes live: without CI through a read-only deploy key, or from GitHub Actions after your tests. In your own Scaleway project.

Merge to main and production follows; push to develop and test does. Choose how: Brewless deploys every push itself, with no pipeline to keep, or your own GitHub Actions run your tests first. Both build in your own Scaleway project.

## What happens after you push.

Brewless itself is released this way: a push to main is live on production in a little over four minutes.

- You push to a branch an environment follows. GitHub tells Brewless with a webhook signed with a secret of this repository only.
- A job in your own Scaleway project fetches the commit with a read-only deploy key and checks that it is still the tip of the branch. What the webhook says is never taken on trust.
- Brewless reads the brewless.yml of that commit. A push may change sizes, release commands and plain variables; anything else waits for a deploy by someone who may manage the application.
- The image is built in your project, release commands such as migrations run, and the release goes live. If anything fails, the release that was live keeps serving.
- A newer push to the same branch overtakes an older one that is still on its way, and a commit that is live already starts nothing.

## Set up once, in about a minute.

Everything happens on the Deploy on push page of your application in the console.

- Paste the SSH address of the repository, such as git@github.com:acme/shop.git. A job in your Scaleway project makes a deploy key; its private half goes straight into your own Secret Manager.
- Choose Place them on GitHub. You install the Brewless GitHub App on that repository, and Brewless puts the read-only deploy key and the webhook on it. Rather do it yourself? Both are shown to copy.
- Say which branch deploys which environment, in the console or with branch: under an environment in brewless.yml.
- Push. The run appears on the page and in the list of all pushes.

## Two ways, both on GitHub.

Deploy on push for a team that wants no pipeline; your own GitHub Actions for a team that wants its tests to pass first. GitLab, Bitbucket and Codeberg are available on request.

|  | Deploy on push | GitHub Actions |
| --- | --- | --- |
| What starts it | A signed webhook from GitHub. | A workflow in your repository that runs brewless deploy. |
| Tests first | No: every push to the branch goes live. | Yes: the deploy waits until your tests pass. |
| Who fetches the code | A job in your own Scaleway project, with a read-only deploy key. | The GitHub runner, which puts it in your own bucket. |
| What GitHub holds | A read-only deploy key and a webhook. The private key stays in your Secret Manager. | A pipeline token that may deploy this one application. |
| What a push may change | Sizes, release commands and plain variables. | All of brewless.yml, with the rights of whoever made the token. |
| Where you follow it | Live in the console, with what the run cost and a mail when it fails. | A check on the commit in GitHub, and the log of the run. |
| What there is to keep | Nothing: no workflow file and no runner. | A workflow file and a token with an end date. |

## GitHub Actions, written for you.

The console makes the workflow from your own environments and branches, with the PHP version of your newest release, and a pipeline token next to it that may only deploy this application.

```yaml
on:
  push:
    branches: ["main", "develop"]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - run: composer install
      - run: php artisan test

  deploy:
    needs: test
    if: github.event_name == 'push'
    steps:
      - run: composer global require brewless/cli
      - name: Deploy production
        if: github.ref == 'refs/heads/main'
        run: brewless deploy production
        env:
          BREWLESS_API_TOKEN: ${{ secrets.BREWLESS_API_TOKEN }}
```

- `on`: Every push and pull request runs the tests; only a push can deploy.
- `test`: Your own tests, with the test commands of your framework.
- `needs`: The deploy waits for the tests, and does not run when they fail.
- `if`: One step per environment, for the branch it follows.
- `secrets`: The token is a repository secret, never in the file. It expires after a year and can be revoked any time.

## What Brewless holds, and what it does not.

Deploying on push without handing anyone the keys to your code.

- **Your code** — Never at Brewless. A job in your own Scaleway project fetches the commit; Brewless only reads its brewless.yml. (`Your Scaleway project`)
- **The deploy key** — Made in memory; the private half goes straight into your Secret Manager and is never stored by Brewless. GitHub holds the public half, read-only. (`Your Secret Manager`)
- **The GitHub App** — Installed only on the repositories you choose. It may manage their deploy keys and webhooks, never read code. Its tokens last one request. (`Repositories you choose`)
- **The webhook** — Signed with a secret of this one repository. A delivery that is not, or that names a commit no longer on the branch, deploys nothing. (`Your repository`)
- **The pipeline token** — For the GitHub Actions route: it may only deploy one application, acts as you, expires after a year and is revoked in the console. (`Your repository secrets`)
- **What a push may change** — Sizes, release commands and plain variables. A database, a bucket or a domain changes only with a deploy by someone who may manage the app. (`brewless.yml`)

## Every run, live.

A list of every push of every application, and a page per run.

- **Step by step** — Each step with how long it took, updating while it runs, with the build log as it grows and the notes a deploy ends with. (`Run page`)
- **What it cost** — The jobs of the push and the build of the release, estimated at Scaleway's list prices: usually a fraction of a cent. (`Run page and Costs`)
- **When it fails** — The release that was live keeps serving, the page says why, and whoever pushed gets a mail. (`Mail to the pusher`)
- **Starting one by hand** — Deploy the newest commit of a branch without pushing, from the same page. (`Deploy the newest commit`)

## Questions about deploying on push

### Does Brewless get access to my code?

No. A job in your own Scaleway project fetches the commit with a read-only deploy key whose private half is in your own Secret Manager. Brewless reads only the brewless.yml of the commit, to know what it asks for.

### Can my tests run before a deploy?

Yes, with the GitHub Actions route. The console writes a workflow that runs your tests on every push and pull request and deploys only when they pass. Deploy on push itself deploys every push to the branch, without tests.

### What happens when two pushes come in quickly?

The newer push overtakes the older one that is still on its way, so only the newest commit goes live. A commit that is live already, or on its way, starts nothing.

### Can a push change my database or my domains?

No. A push may change sizes, release commands and plain variables. A change to a resource, such as a database, a bucket or a domain, is refused until someone who may manage the application deploys it.

### Does it cost extra?

Deploy on push is in every plan, the free one included. The jobs that fetch a commit run in your own Scaleway project and usually cost a fraction of a cent per push; the console shows what each run cost.

### Can I use GitLab or Bitbucket?

Deploy on push works with GitHub. GitLab, Bitbucket and Codeberg are available on request: write to hi@brewless.eu and we turn them on for your organisation.

## Read more

- [Deploy on push in the documentation](https://docs.brewless.eu/deployments/deploy-on-push)
- [Deploying from a pipeline](https://docs.brewless.eu/deployments/from-a-pipeline)
- [Deploy a Laravel app on every push without a CI pipeline](https://brewless.eu/blog/deploy-laravel-on-every-push)
- [Security and trust](https://brewless.eu/security)
