GitHub Webhooks
OliveTin includes built-in templates for GitHub webhooks that simplify configuration. Instead of manually configuring header matching and argument extraction, you can use a template that handles all the common settings for you.
Supported GitHub Templates
OliveTin supports the following GitHub webhook templates:
-
github-push- Triggered on push events -
github-prorgithub-pull-request- Triggered on pull request events -
github-release- Triggered on release events -
github-workflow- Triggered on workflow run events
Setting Up GitHub Webhooks
1. Configure the Webhook in GitHub
-
Go to your GitHub repository → Settings → Webhooks → Add webhook
-
Set the Payload URL to
http://your-olivetin-server:1337/webhooks -
Set Content type to
application/json -
Enter a Secret (you’ll use this in your OliveTin config)
-
Choose which events to trigger the webhook:
-
Select Just the push event for push triggers
-
Or select Let me select individual events for more control
-
-
Click Add webhook
2. Configure OliveTin
Use the template property to apply GitHub-specific settings:
config.yamlactions:
- title: Deploy on Push
shell: |
echo "Deploying commit {{ git_commit }} to {{ git_branch }}"
/opt/scripts/deploy.sh "{{ git_branch }}"
arguments:
- name: git_commit
type: ascii
- name: git_branch
type: ascii
execOnWebhook:
- template: github-push
secret: your-github-webhook-secret
GitHub Push Template
The github-push template is designed for push events. It automatically:
-
Sets authentication to HMAC-SHA256 with the
X-Hub-Signature-256header -
Matches the
X-GitHub-Event: pushheader -
Extracts common push event data
Extracted Arguments
The following arguments are automatically extracted and available in your action:
| Argument Name | Description | JSONPath |
|---|---|---|
|
Full repository name (owner/repo) |
|
|
Full git reference (e.g., refs/heads/main) |
|
|
The HEAD commit SHA |
|
|
The branch reference |
|
|
The commit message |
|
|
The commit author’s name |
|
Example: Deploy on Push to Main
actions:
- title: Deploy to Production
shell: |
if [ "{{ git_ref }}" = "refs/heads/main" ]; then
echo "Deploying {{ git_commit }} by {{ git_author }}"
/opt/scripts/deploy.sh production
else
echo "Ignoring push to non-main branch"
fi
arguments:
- name: git_ref
type: ascii
- name: git_commit
type: ascii
- name: git_author
type: ascii
execOnWebhook:
- template: github-push
secret: your-secret
GitHub Pull Request Template
The github-pr (or github-pull-request) template handles pull request events.
Extracted Arguments
| Argument Name | Description | JSONPath |
|---|---|---|
|
Pull request number |
|
|
Pull request title |
|
|
PR author’s username |
|
|
Event action (opened, closed, synchronize, etc.) |
|
|
Full repository name |
|
|
PR state (open, closed) |
|
|
HEAD commit SHA of the PR branch |
|
Example: Run Tests on PR
actions:
- title: Run PR Tests
shell: |
echo "Running tests for PR #{{ pr_number }}: {{ pr_title }}"
echo "Action: {{ pr_action }}, Author: {{ pr_author }}"
/opt/scripts/run-tests.sh "{{ pr_head_sha }}"
arguments:
- name: pr_number
type: ascii
- name: pr_title
type: ascii
- name: pr_action
type: ascii
- name: pr_author
type: ascii
- name: pr_head_sha
type: ascii
execOnWebhook:
- template: github-pr
secret: your-secret
Example: Only on PR Open or Synchronize
actions:
- title: CI Build
shell: /opt/scripts/ci-build.sh "{{ pr_head_sha }}"
arguments:
- name: pr_head_sha
type: ascii
execOnWebhook:
- template: github-pr
secret: your-secret
matchPath: '$.action="opened"'
- template: github-pr
secret: your-secret
matchPath: '$.action="synchronize"'
GitHub Release Template
The github-release template handles release events.
Extracted Arguments
| Argument Name | Description | JSONPath |
|---|---|---|
|
Release action (published, created, etc.) |
|
|
Release tag name |
|
|
Release name/title |
|
|
Full repository name |
|
|
Release author’s username |
|
Example: Deploy on Release
actions:
- title: Deploy Release
shell: |
echo "Deploying release {{ release_tag }}: {{ release_name }}"
/opt/scripts/deploy-release.sh "{{ release_tag }}"
arguments:
- name: release_tag
type: ascii
- name: release_name
type: ascii
execOnWebhook:
- template: github-release
secret: your-secret
matchPath: '$.action="published"'
GitHub Workflow Template
The github-workflow template handles workflow run events, useful for triggering actions when GitHub Actions workflows complete.
Extracted Arguments
| Argument Name | Description | JSONPath |
|---|---|---|
|
Name of the workflow |
|
|
Workflow status |
|
|
Workflow conclusion (success, failure, etc.) |
|
|
Full repository name |
|
|
HEAD commit SHA |
|
|
Branch that triggered the workflow |
|
Example: Deploy After CI Success
actions:
- title: Deploy After CI
shell: |
echo "CI workflow '{{ workflow_name }}' completed with {{ workflow_conclusion }}"
if [ "{{ workflow_conclusion }}" = "success" ]; then
/opt/scripts/deploy.sh "{{ git_branch }}" "{{ git_commit }}"
fi
arguments:
- name: workflow_name
type: ascii
- name: workflow_conclusion
type: ascii
- name: git_branch
type: ascii
- name: git_commit
type: ascii
execOnWebhook:
- template: github-workflow
secret: your-secret
matchPath: '$.action="completed"'
Customizing Templates
Templates provide default values, but you can override or extend them:
actions:
- title: Custom Push Handler
shell: echo "Push from {{ custom_field }}"
arguments:
- name: custom_field
type: ascii
- name: git_commit
type: ascii
execOnWebhook:
- template: github-push
secret: your-secret
# Add additional extractions
extract:
custom_field: "$.sender.login"
# Add additional match criteria
matchPath: '$.repository.private=false'
Custom extract values are merged with template defaults, so you can add extra fields without losing the standard ones.
Security Considerations
-
Always use a secret - Without a secret, anyone can trigger your webhooks
-
Use HTTPS - When exposing OliveTin to the internet, use a reverse proxy with TLS
-
Limit webhook events - Only subscribe to the events you actually need in GitHub
-
Validate in your scripts - Add additional validation in your shell scripts for sensitive operations
Troubleshooting
Webhook Not Triggering
-
Check the OliveTin logs with
logLevel: DEBUGfor webhook processing details -
Verify the webhook is being received (check GitHub webhook delivery history)
-
Ensure the secret matches exactly between GitHub and OliveTin config
-
Verify the
templatename is spelled correctly
See Also
-
Webhooks Overview - General webhook configuration
-
GitOps Solution - Alternative approach using Git hooks
-
GitHub Webhooks Documentation - Official GitHub webhook documentation