Skip to content

This webhook performs a docker rm on webhook call with the DELETE event

Notifications You must be signed in to change notification settings

DanildZambrana/docker-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker rm WEBHOOK

Description

This is a simple webhook that listens for POST requests and runs a shell script. It is intended to be used in a Docker container.

Usage

BUILD

Set the environment variables

export WEBHOOK_SECRET=secret

Build the Docker image

docker build -t webhook .

Or get them from github docker registry

docker pull ghcr.io/danildzambrana/docker-webhook:main

You can check the image is downloaded with the following command:

docker images ls

and check the image is in the list.

Run the Docker container

docker run -p 5030:80 --privileged --name webhook -e WEBHOOK_SECRET -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/danildzambrana/docker-webhook:main uvicorn main:app --host 0.0.0.0 --port 80

or you can run the compose file compose.yml with the following command:

Note

Remember to check the image name in the compose file, if you build the image with the name webhook you don't need to change anything, otherwise you need to change the image name in the compose file.

docker-compose up -d

Test the webhook

curl -X POST http://localhost:5030/webhook

Configure the webhook on github

  1. Go to the repository settings
  2. Click on Webhooks
  3. Click on Add webhook
  4. Set the Payload URL to http://localhost:5030/webhook
  5. Set the Content type to application/json
  6. Set the Secret to the value of the environment variable WEBHOOK_SECRET
  7. Select the event DELETE in the events section
  8. Click on Add webhook
  9. Delete a branch in the repository
  10. Check the logs of the webhook container
  11. The webhook should have received the POST request and executed the shell script
  12. The branch should have been deleted

Stop the Docker container

docker stop webhook

Remove the Docker container

docker rm webhook

About

This webhook performs a docker rm on webhook call with the DELETE event

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages