Skip to content

bxtp4p/repository-dispatch-webhook-receiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Example webhook that can receive repository events and relay the headers and payload to an Actions workflow using repository_dispatch.

This uses docker-webhook.

Build the Image

docker image build --rm -t repository-dispatch-webhook . 

Run the Receiver

Set the following environment variables:

export WEBHOOK_SECRET=[[mysecret]]
export GH_TOKEN=[[your pat token]]
export OWNER=[[owner]]
export REPO=[[repo]]
export EVENT_TYPE=[[example]]

Run the following:

docker run -d -p 9000:9000 \
   -v $PWD/scripts:/var/scripts \
   -v $PWD/hooks:/etc/webhook \
   -e WEBHOOK_SECRET=${WEBHOOK_SECRET} \
   -e GH_TOKEN=${GH_TOKEN} \
   -e OWNER=${OWNER} \
   -e REPO=${REPO} \
   -e EVENT_TYPE=${EVENT_TYPE} \
   --name=webhook \
   repository-dispatch-webhook -verbose -hooks=/etc/webhook/hooks.json -hotreload -template

If you're running this locally, you can expose this publicly via ngrok or localtunnel.

Receiver Environment Variables

Environment Variable Description
WEBHOOK_SECRET The secret the receiver should use to evaluate the request. Needs to be the same as what is configured in your GitHub webhook settings.
GH_TOKEN GitHub Personal Access Token used to make the call to the GitHub REST API repository /dispatches endpoint.
OWNER The owner of the repo to send the event to
REPO The repo to send the event to
EVENT_TYPE The event type the Actions workflow is expecting

GitHub Webhook Configuration

Setting Value
Payload URL {RECEIVER_ADDRESS}/hooks/repository-dispatch
Content Type application/json
Secret Same value as the WEBHOOK_SECRET environment variable above

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published