7 - Triggers
Triggers automate deployments using a variety of conditions, such as Git events, new artifacts, schedules, and the success of other pipelines.
Now that you have an Artifact Build and Deploy Pipeline, you can create a Harness Trigger that runs the Pipeline in response to a Git push to the source repo. The Trigger provides a Webhook URL you can add to your Git repo.
When the push event happens, Git sends a HTTP POST payload to the Webhook's configured URL. The Trigger then executes Artifact Build and Deploy Pipeline.
To add a Trigger, do the following:
- In your Harness Application, click Triggers, and then click Add Trigger. The Trigger dialog appears.
- In Name, enter a name for your Trigger, such as Build and Deploy.
- Click Next.
- In Condition, in Type, select On Webhook Event.
- In Repository Type, select the Git repo, such as GitHub.
- In Event Type, choose On Push. At this point, the Trigger will look something like this:
- Clic Next.
- In Actions, in Execution Type, select Pipeline.
- In Execute Pipeline, select your Artifact Build and Deploy Pipeline.
- Click Next and then SUBMIT. The Trigger is created.
- Click GitHub Webhook. The Trigger dialog appears.
- Copy the Webhook and use it in GitHub to trigger the deployment.
- When you set up the Webhook in GitHub, modify the Content type to application/json.
- In Which events would you like to trigger this webhook?, select Just the push event.
Save your Webhook. The next time a push even occurs, the Harness examines any incoming payload to ensure that it meets the Action you set in your Trigger. The Trigger you created will run, executing your Artifact Build and Deploy Pipeline.