Deploy a commit to an environment.
For example, deploy(project="shop", environment="prod", ref="main").
Use it after a push or a ``commit_files`` call, because a push or
a commit deploys nothing. The deploy rolls out every service that
is turned on in the environment, or the ``services`` you name.
``ref`` is a branch name (e.g. ``"main"`` or ``"refs/heads/main"``):
xhostd deploys the current HEAD of that branch and binds the
environment to it, so a later deploy of that branch can omit
``ref``. ``sha`` is a 40-char hex commit: it ships that commit once
and never changes the binding. If both are given, ``sha`` takes
precedence and the call ignores ``ref``. Omit both to deploy the
HEAD of the branch the environment is bound to. An environment with
no branch yet (a new project's
prod, unless create_project named one) answers 400
``channel_unbound``; deploy with ``ref``, or bind it with
update_environment. A bound branch missing from the repo answers
404; both errors name the source repository's default branch when
the project has one.
On a project with a connected source repository, the deploy
fetches from it first. A 503 that says another write (a push, a
commit_files call, or another sync) holds the project's repo, or
that the project is under scheduled maintenance, changes nothing.
Retry in a minute. A 503 that says the fetch did not finish in 40
seconds queued nothing: the platform completes the fetch, records
its result as the sync status that get_project shows, and deploys
each environment that follows a branch that moved. Read that
status before you deploy again.
Returns {deploy_id, channel_id, status, joined}. ``joined`` is true
when a deploy of the same commit, queued by a deploy request or by
a push to the connected source repository, is already waiting for
this environment. ``deploy_id``
names that deploy, and no second deploy was queued. It reads the
current variables when it starts, so poll it as usual. Deploy runs
asynchronously;
poll get_logs with source="deploy" and read the status in its first
line — get_project's pending_deploy also shows the in-flight
deploy. For 'docker'-template services the deploy builds the image
first — the log streams '[build] ...' lines (queue position, build
duration, image size vs plan cap). A call that the client declines
never reaches xhostd and queues nothing.
Reference: https://docs.xhostd.com/mcp-tools#deploy