Flow Deploy includes a composite GitHub Action that handles host discovery, GHCR authentication, and SSH-based deployment. This guide walks through setting up automated deploys from CI.
The deploy pipeline:
- CI builds your Docker image and pushes it to GHCR under the release version (when there is one) and the commit SHA
- The deploy action discovers hosts from your
docker-compose.yml - For each host: authenticates with GHCR and runs
flow-deploy deploy --tag <version or sha>(which handles git fetch and checkout internally)
The deploy tag is both the git ref checked out on the server and the image tag pulled, so:
- Push the image under every tag you deploy by, and always under the full commit SHA. Typically the version tag (
v1.4.0) for releases plus${{ github.sha }}. A failed deploy restores by the tag that was running when it's a git ref, else by the SHA of the commit that was checked out.:latestis optional; flow-deploy never relies on it. - Name every app image with
DEPLOY_TAG, directly or through.env:
# docker-compose.yml
services:
web:
image: ${DOCKER_IMAGE}# .env on the server
DOCKER_IMAGE=ghcr.io/yourorg/yourproject:${DEPLOY_TAG:-latest}A bare DOCKER_IMAGE=ghcr.io/yourorg/yourproject (no tag) always runs :latest, whatever you deploy; flow-deploy warns when it sees that.
- Use
flow-deploy composefor manual commands on the server (flow-deploy compose up -d,flow-deploy compose run --rm web ...). With${DEPLOY_TAG:-latest}, a plaindocker compose up -dwould move every service to:latest;flow-deploy composesetsDEPLOY_TAGto the deployed tag. Or havescript/proddefault it (see the README's Image Tags section).
Version tags can be lightweight or annotated, and a re-pushed tag is picked up: flow-deploy runs git fetch --tags --force. If a deploy fails, every service goes back to the image it was running, named by its release tag or commit SHA.
On your deploy server:
- Docker and Docker Compose
- Traefik (or your reverse proxy) running
- Git (
flow-deployhandlesgit fetchand detached checkout internally during each deploy) flow-deployinstalled:
curl -fsSL https://deploy.flowcanon.com/install | shFlow Deploy takes over the update cycle — you still do the initial setup manually.
1. Clone your project on the server:
git clone git@github.com:yourorg/yourproject.git /srv/yourproject
cd /srv/yourproject2. Create your .env file:
cp .env.example .env
# Edit with your values3. Install flow-deploy:
curl -fsSL https://deploy.flowcanon.com/install | sh4. Start the stack at the version you're deploying (with DEPLOY_TAG unset, ${DEPLOY_TAG:-latest} runs :latest):
git checkout --detach v1.4.0
DEPLOY_TAG=v1.4.0 docker compose up -dOr do the first deploy with flow-deploy itself: flow-deploy deploy --tag v1.4.0.
From this point, CI handles all subsequent deploys.
Generate a deploy key:
ssh-keygen -t ed25519 -C "deploy@yourproject" -f deploy_key -N ""- Add
deploy_key.pubto the server's~/.ssh/authorized_keysfor your deploy user - Add
deploy_key(the private key) as a GitHub secret:DEPLOY_SSH_KEY
If you want to keep host details out of your compose file (recommended for public repos), create a GitHub environment and set these variables:
| Variable | Description | Example |
|---|---|---|
HOST_NAME |
Server hostname or IP | app-1.example.com |
HOST_USER |
SSH user | deploy |
SSH_PORT |
SSH port (omit for 22) | 2222 |
These override x-deploy values from your compose file. Set them in:
Settings > Environments > [your environment] > Environment variables
Your workflow needs environment: your-environment-name on the deploy job to access these.
| Secret | Description |
|---|---|
DEPLOY_SSH_KEY |
Private SSH key for the deploy user |
GITHUB_TOKEN |
Provided automatically — used for GHCR auth on the server |
Use the standalone action from flowcanon/deploy-action.
| Input | Required | Default | Description |
|---|---|---|---|
tag |
Yes | — | Tag to deploy: the version tag, or the commit SHA |
ssh-key |
Yes | — | SSH private key |
command |
No | script/prod |
Compose command |
host |
No | — | Override deploy host |
user |
No | — | Override deploy user |
ssh-port |
No | — | Override SSH port |
registry-token |
No | — | GHCR token for server auth |
Pushes to master deploy by commit SHA; pushing a version tag deploys that version.
name: Deploy
on:
push:
branches: [master]
tags: ["v*"]
env:
IMAGE: ghcr.io/yourorg/yourproject
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The version tag on tag pushes, and always the full SHA.
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=ref,event=tag
type=sha,format=long,prefix=
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
- uses: flowcanon/deploy-action@master
with:
tag: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
host: ${{ vars.HOST_NAME }}
user: ${{ vars.HOST_USER }}
ssh-port: ${{ vars.SSH_PORT }}
registry-token: ${{ secrets.GITHUB_TOKEN }}When a release job creates the version tag itself (for example salsify/action-detect-and-tag-new-version, whose tag output is empty when no new version was detected), push the image under that tag and the SHA, and deploy by the tag with the SHA as the fallback:
- uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ env.IMAGE }}:${{ github.sha }}
${{ needs.release.outputs.created-tag && format('{0}:{1}', env.IMAGE, needs.release.outputs.created-tag) || '' }}
- uses: flowcanon/deploy-action@master
with:
tag: ${{ needs.release.outputs.created-tag || github.sha }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}The tag must be pushed to the repository before the deploy runs, since flow-deploy fetches it on the server.
For each host group discovered from your compose config:
- SSH agent — loads your deploy key
- Discover hosts — parses
docker-compose.ymlforx-deployanddeploy.*labels, groups services by(host, user, port, dir) - GHCR login — authenticates Docker on the server (and logs out after)
- Deploy — runs
flow-deploy deploy --tag <tag>on the server (git fetch and detached checkout are handled by the tool)
The action discovers where to deploy from your compose file:
x-deploy:
host: app-1.example.com
user: deploy
port: 22
dir: /srv/myappPriority order (highest wins):
- GitHub Actions variables (
vars.HOST_NAME,vars.HOST_USER,vars.SSH_PORT) - Per-service labels (
deploy.host,deploy.user,deploy.port,deploy.dir) x-deploytop-level defaults
This means you can keep x-deploy in your compose file for local/development use and override with GitHub variables for production — keeping real hostnames out of version control.
For services spread across multiple hosts:
x-deploy:
user: deploy
dir: /srv/myapp
services:
web:
labels:
deploy.role: app
deploy.host: web-1.example.com
worker:
labels:
deploy.role: app
deploy.host: worker-1.example.com
deploy.dir: /srv/workerThe action groups services by (host, user, port, dir) and deploys to each group sequentially.
To cut releases with binaries and changelogs, see the release workflow in this repo which uses:
salsify/action-detect-and-tag-new-versionfor version detectionsoftprops/action-gh-releasefor GitHub releases with musl/glibc binariesflowcanon/release-builderfor changelogs and version bumps
working tree is dirty — deploy aborted:
The server repo has uncommitted changes. SSH into the server and resolve manually — git status will show what's dirty.
unauthorized pulling from GHCR:
Pass registry-token: ${{ secrets.GITHUB_TOKEN }} to the deploy action. The job needs packages: write (or at least packages: read) permission.
flow-deploy: command not found:
Install it on the server: curl -fsSL https://deploy.flowcanon.com/install | sh
Then start a new login shell or run . ~/.profile.
warning: web's image (...) doesn't use DEPLOY_TAG:
The rendered image doesn't end in :<tag>, so the deploy doesn't change what that service runs. Make the image (or DOCKER_IMAGE in .env) end in :${DEPLOY_TAG:-latest}.
manifest unknown pulling <image>:v1.4.0:
CI didn't push the image under that tag. Push the version tag as well as the SHA, or deploy by SHA.
can't tell which tag is deployed from flow-deploy tag or flow-deploy compose:
Services run different or untagged images (one image under :latest plus one other tag is fine), or nothing is running and no deploy is recorded. Set it explicitly: DEPLOY_TAG=v1.4.0 flow-deploy compose up -d.
WARNING: compose config failed with this environment ... (unset: DOCKER_IMAGE) from host discovery:
CI has no .env, so variables only set there are empty. Discovery retries without interpolation and carries on; the warning names the variables. It only matters if x-deploy or a deploy.* label uses them: set those in CI, or use the HOST_NAME/HOST_USER/SSH_PORT overrides.
didn't exit on SIGTERM ... and was killed:
The container's PID 1 isn't handling SIGTERM, so every deploy waits out the drain and kills it mid-request. Use an exec-form CMD (["gunicorn", ...]), or exec the server at the end of the entrypoint script.
How did a deploy end, when CI was cancelled?
On the host: flow-deploy status (last run and exit code), or .git/flow-deploy.log.
Health check timeout:
Increase the timeout via label: deploy.healthcheck.timeout: 300. Check that your app's health endpoint responds within the Docker healthcheck interval.