Deploy hooks

Published

Updated

🪝

Hook up deployments.

A deploy hook is a secret URL that deploys a fortrabbit environment when it receives a POST request. A headless CMS, a CI pipeline or a cron job can deploy this way, without a git push.

Deploy hooks are unique URLs that accept HTTP POST requests to trigger a deployment on an environment.

Settings

Deploy hooks are configured in the fortrabbit dashboard for each environment.

Enabling the deploy hook shows its URL. Store it like a password.

Trigger

Send a POST request to the URL. No authentication and no payload are needed:

# Trigger
curl -X POST "https://api.fortrabbit.com/webhooks/environments/{{app-env-id}}/deploy/{{SECRET}}" \
  -H "User-Agent: fortrabbit"
bash

A started deployment answers with status 202 and the ID of the deployment:

{
  "data": {
    "publicId": "dp-abc123"
  }
}
json

A wrong URL, a revoked secret or a disabled deploy hook all answer with status 404:

{
  "error": "Not found"
}
json

Use cases

  • Deploy when a headless CMS such as Contentful or Strapi publishes
  • Deploy on a schedule, from a cron job or a workflow tool
  • Deploy from a CI pipeline after the tests passed

Example

A GitHub Actions step that triggers a deployment, with the URL stored as a secret:

deploy:
  runs-on: ubuntu-latest
  steps:
    - name: Trigger fortrabbit deploy
      run: |
        curl -X POST "${{ secrets.FORTRABBIT_DEPLOY_HOOK_URL }}" \
          -H "User-Agent: fortrabbit"
yaml

The hook deploys the latest commit of the connected branch, not the commit the workflow ran on. See GitHub for more on GitHub Actions.

For day-to-day work, push to deploy with the GitHub App needs no hook.

Security

Anyone with the URL can deploy the environment. The hook ignores the deployment permission and the deployment trigger. Treat the URL like a password or API token. When it leaks, revoke it in the dashboard and create a new one.

Troubleshooting

When a deploy hook does not deploy:

  • 404 response: the URL is wrong, revoked, or the hook is disabled. Copy the URL again from the dashboard.
  • No response: the calling service cannot reach api.fortrabbit.com.
  • 202 response: the deployment started. Its result shows in the deployment history of the environment.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗