cs-icon.svg

Deploy Hooks

A deploy hook allows you to trigger a deployment using a unique URL.

The following are some of the example use cases for Deploy Hooks:

  • Rebuilding your site to reflect changes in a Headless CMS
  • Scheduling deployments with Cron Jobs

This document guides you through the process of creating, triggering, renaming, and deleting a deploy hook in Launch.

Prerequisites

  1. Contentstack account
  2. Access to Launch for your organization
  3. A project already deployed in Launch

Create a Deploy Hook

Follow the steps given below to create a deploy hook in your project:

  1. From the Launch landing page, click the project card to open your project.
  2. In the Environments screen, go to the environment where you created the project, click the ellipses under Actions, and then click Settings to configure the deploy hook. For this tutorial, we will be adding a deploy hook to the Default environment.
  3. Launch_Venus2_Env_Settings

  4. In Environments under Settings, click Deploy Hooks.
    Launch_Deploy_Hooks_Venus2_Tab_GitHub.png
  5. Click the + New Deploy Hook button.
  6. Enter a name for your deploy hook.

    Note: The deploy hook name is for your reference. This name will be displayed in your list of deploy hooks.

    Launch_Deploy_Hooks_Venus2_NewDeployModal.png
  7. Click the Create Deploy Hook button.
    Launch provides you with a unique URL for this deploy hook.
    Launch_Deploy_Hooks_Venus2_URL.png

Trigger a Deploy Hook

Follow the steps given below to trigger a deploy hook:

  1. Click the Environments icon in the left panel.
  2. In the Default environment, click the ellipses under Actions, and then click Settings to go to the Settings page.
  3. Launch_Venus2_Env_Settings

  4. In Environments under Settings, click Deploy Hooks.
  5. Click the ellipses under Actions and then click Copy URL to copy the deploy hook URL.
    Launch_Deploy_Hooks_Venus2_CopyURL.png
  6. Send a POST request to this URL to trigger the deploy hook you created.

    Example Request

    curl -X POST
    https://cs-domain.com/Launch-path/manage/deploy/deploy-hook-id
    
    

    Example Response

    {
     "message": "Deployment triggered successfully"
    }
    
  7. Click the Environments icon in the left panel and then go to your environment.

You will see that it has triggered a deployment successfully.

Launch-Deploy_Hooks-DeploymentInfo.png

If you used a git repository to import your project, then by default, the deploy hook uses the latest commit from the git branch for the deployment.

Parameter used in a Deploy Hook

Deploy hooks accept the following optional URL query parameter:

  • commit: Parameter that specifies which git commit to deploy on triggering the deploy hook.

Here's an example where a deploy hook URL uses the commit parameter:

curl -X POST 
https://cs-domain.com/Launch-path/manage/deploy/h83y7hreohuuererh7343?commit=rbg734c

The commit can be the full SHA or just the first seven characters of your full SHA.

Note: When you import a project by uploading a file, you should not pass the commit parameter.

Rename a Deploy Hook

Follow the steps given below to rename a deploy hook:

  1. Click the Environments icon in the left panel.
  2. In the Default environment, click the ellipses under Actions, and then click Settings to go to the Settings page.
  3. Launch_Venus2_Env_Settings

  4. In Environments under Settings, click Deploy Hooks.
    Launch_Deploy_Hooks_Venus2_Tab_GitHub.png
  5. Click the ellipses under Actions and then click Edit to edit the deploy hook URL.
    Launch_Deploy_Hooks_Venus2_EditURL.png

Delete a Deploy Hook

Follow the steps given below to delete a deploy hook:

  1. Click the Environments icon in the left panel.
  2. In the Default environment, click the ellipses under Actions, and then click Settings to go to the Settings page.
  3. Launch_Venus2_Env_Settings

  4. In Environments under Settings, click Deploy Hooks.
    Launch_Deploy_Hooks_Venus2_Tab_GitHub.png
  5. Click the ellipses under Actions and then click Delete to delete the deploy hook URL.
    Launch_Deploy_Hooks_Venus2_DeleteURL.png
Was this article helpful?
^