Skip to content
Latchkey

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

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card