Hosted: Deploys

Hosted

Deploys

Deploy to your own server after checks pass, with approval in Slack, a health check, and rollback.

A deploy runs on the same agent that ran your checks, on the server you already control. The hub coordinates and asks for approval. It does not hold your server credentials, and your source code is not sent to it.

The deployments section

Deployments are declared per environment in .hookci.yml, next to checks.

version: 1
deployments:
  production:
    on: { push: { branch: main } }
    strategy: restart
    target: /srv/app
    build: npm run build
    migrate: npm run migrate
    env_file: /etc/app.env
    health: { url: http://127.0.0.1:3000/health, timeout: 60s }
    rollback: auto
    approve: true
Field Meaning
on When the deploy is triggered, for example a push to main.
strategy restart or compose-bluegreen. See below.
target Directory on the agent host where the app lives.
build Command that builds the release.
migrate Command that runs database migrations before the switch.
env_file File with runtime environment, read on the host. Its contents are never uploaded.
health URL the agent polls after the switch, and how long to wait.
rollback What to do when the health check fails. auto is the planned default shape and is a design value.
approve When true, a person must approve in Slack before the deploy starts.

Strategies

  • restart: update the code in target, build, migrate, then restart the service. Simple, with a short gap while the process restarts.
  • compose-bluegreen: for Docker Compose apps. Start the new version next to the old one, wait for the health check, then switch over and stop the old one. This is intended to avoid downtime for stateless services.

Approval flow in Slack

With approve: true, a passing run on the deploy branch posts an approval card to the bound Slack channel instead of deploying immediately.

Illustration. Design of a production deploy approval card with commit, health check result, and Approve and Reject buttons.
  1. Bind the repo and agent to a deploy target in Slack:

    /hookci bind acme/web build-box deploy:production
  2. Push to the configured branch. The checks run first.

  3. When checks pass, the card appears. Approve or Reject.

  4. On approval, the agent builds, migrates, switches, and polls the health URL. The result is reported back to the card.

bind <repo> <agent> [checks|deploy:<env>] is the same bind command used for checks. The deploy environment name must match a key under deployments. See Slack for the other commands.

Health check and rollback

After the switch the agent requests health.url until it returns a success status or health.timeout passes. On failure, rollback decides what happens. The intended behaviour of auto is to restore the previous release and report the failure on the card. This detail is design and not verified.

Things to know

  • Run deploys on a host you trust. Deploy commands are your own scripts and run with the access the agent gives them.
  • Use hookci validate to check the file once the schema ships. See the .hookci.yml reference.
  • Notifications for deploys use notify.slack.on: [deploy].