Auto Build
Auto Build enables automatic component builds when code is pushed to a Git repository. Instead of manually triggering builds, you can configure components to build automatically whenever changes are pushed to the repository.
Prerequisitesβ
Before configuring auto-build, ensure you have:
- OpenChoreo installed and running
- Workflow plane installed in your OpenChoreo cluster
- A Component created in OpenChoreo pointing to a Git repository
- Access to create webhooks in your Git repository
Configurationβ
Step 1: Create the Webhook Secretβ
Create a Kubernetes secret to store the webhook secret that will be used to validate incoming webhooks:
# Generate a random secret
WEBHOOK_SECRET=$(openssl rand -hex 32)
echo "Your webhook secret: $WEBHOOK_SECRET"
# Create the Kubernetes secret
kubectl create secret generic git-webhook-secrets \
-n openchoreo-control-plane \
--from-literal=github-secret="$WEBHOOK_SECRET"
# Verify the secret was created
kubectl get secret git-webhook-secrets -n openchoreo-control-plane
Save the $WEBHOOK_SECRET value. You will need it when configuring the webhook in your Git provider.
Step 2: Configure the Webhook in Your Git Providerβ
Create a webhook in your Git provider that points to OpenChoreo's webhook endpoint. OpenChoreo uses a single unified endpoint (/api/v1alpha1/autobuild) for all Git providers β the provider is identified automatically from the request headers sent by the Git provider (e.g. X-GitHub-Event for GitHub, X-Event-Key for Bitbucket).
The following example shows how to configure this in GitHub:
- Go to your repository
- Navigate to Settings > Webhooks > Add webhook
- Configure the webhook:
| Field | Value |
|---|---|
| Payload URL | https://<your-openchoreo-api-domain>/api/v1alpha1/autobuild |
| Content type | application/json |
| Secret | The $WEBHOOK_SECRET you generated in Step 1 |
| Which events | Select "Just the push event" |
| Active | Checked |
- Click Add webhook
GitHub will send a test ping event. You should see a green checkmark if the webhook was delivered successfully.
Step 3: Enable Auto-Build on Componentsβ
Developers enable auto-build on their Components by setting autoBuild: true. See the developer Auto-Build guide for the Component configuration and field reference.
Step 4: Verifyβ
After a developer enables auto-build on a Component and pushes code, verify a WorkflowRun is created:
kubectl get workflowrun
Local Development Testingβ
For local testing with a development cluster, you can use ngrok to expose your local OpenChoreo instance to receive webhooks from your Git provider:
ngrok http --host-header=api.openchoreo.localhost 8080
Use the ngrok HTTPS URL as your webhook payload URL:
https://abc123xyz.ngrok-free.app/api/v1alpha1/autobuild