How to Trigger a Workflow From an External Webhook in GitHub Actions
Not every trigger is a push or a tag; sometimes a deploy tool or SaaS event needs to kick off CI from the outside.
Listen for repository_dispatch with a chosen event_type, then have the external system POST to the dispatches endpoint with a PAT.
Steps
- Add an on: repository_dispatch trigger with the event types you accept.
- Create a token with repo scope for the caller to authenticate with.
- POST to /repos/OWNER/REPO/dispatches with an event_type that matches.
- Read the dispatched data inside the workflow from the event payload.
Workflow
.github/workflows/external-trigger.yml
name: External Trigger
on:
repository_dispatch:
types: [deploy-requested]
jobs:
run:
runs-on: ubuntu-latest
steps:
- run: echo "triggered by ${{ github.event.action }}"
# Caller:
# curl -XPOST -H "Authorization: token $TOKEN" \
# https://api.github.com/repos/OWNER/REPO/dispatches \
# -d '{"event_type":"deploy-requested"}'Notes
- repository_dispatch always runs on the default branch, so versioned logic must live there.
- Latchkey managed runners pick up these externally triggered jobs cheaper and self-heal on runner loss.
Frequently asked questions
How do I trigger a Workflow From an External Webhook in GitHub Actions?
Listen for repository_dispatch with a chosen event_type, then have the external system POST to the dispatches endpoint with a PAT.
Related guides
How to Set a Matrix From Previous Job Output in GitHub ActionsBuild a dynamic GitHub Actions matrix from a previous jobs output by emitting a JSON array to GITHUB_OUTPUT a…
How to Trigger a Workflow on Push to Specific Branches in GitHub ActionsRun a GitHub Actions workflow only when commits are pushed to named branches using on.push.branches, so featu…
How to Set a Commit Status from GitHub ActionsSet a custom commit status from GitHub Actions with the GITHUB_TOKEN and the statuses API, so an external che…