Skip to content

Deploy without the CLI

hiraiship deploy is a few HTTP requests. This recipe makes them with curl, for a platform or a pipeline that can't run the CLI. You need a key with the developer role in HIRAISHIP_TOKEN.

  1. Create the project

    Skip this step if the project exists: get it by slug instead.

    Terminal
    curl -X POST https://api.hiraiship.com/api/v1/projects \
      -H "Authorization: Bearer $HIRAISHIP_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{ "name": "Acme site", "slug": "acme-site" }'

    The response holds the project, its production environment and its default domain. Keep the environment's id:

    Terminal
    export ENVIRONMENT_ID=9a1b7c3d-5e2f-4a8b-b6c4-2d8e1f9a5c31
  2. Pack the source

    The source travels as a gzipped tar, base64-encoded. Pack the project directory, not its build output: Hiraiship installs and builds it. Leave out what the CLI leaves out: node_modules, .git, .hiraiship and .env files.

    Terminal
    tar -czf source.tgz --exclude=node_modules --exclude=.git --exclude=.hiraiship --exclude='.env*' -C ./my-app .
  3. Start the deployment

    Terminal
    jq -n --rawfile tarball <(base64 -w0 source.tgz) \
      '{ sourceTarballBase64: $tarball, triggerSource: "cli" }' \
    | curl -X POST "https://api.hiraiship.com/api/v1/environments/$ENVIRONMENT_ID/deployments" \
      -H "Authorization: Bearer $HIRAISHIP_TOKEN" \
      -H "Content-Type: application/json" \
      -d @-

    The answer is a 202 with the deployment, pending (building) or queued (waiting for a build slot). Keep its id as DEPLOYMENT_ID. Add gitSha and commitMessage to the body to see them in the dashboard. On macOS, base64 -i source.tgz replaces base64 -w0 source.tgz.

  4. Follow the build

    Terminal
    curl -N "https://api.hiraiship.com/api/v1/deployments/$DEPLOYMENT_ID/stream" \
      -H "Authorization: Bearer $HIRAISHIP_TOKEN"

    The stream ends with a done event. When status is success and dispatchStatus is live, the deployment serves traffic at its deployedUrl. See Streaming for the events, or poll Get a deployment.

Build settings

Hiraiship detects the framework and its commands. To override them for every deployment, update the project's build settings; for one deployment only, add installCommand, buildCommand, outputDir or machine to the deployment's body.