Last active
February 1, 2018 18:37
-
-
Save EamonKeane/4bc74fab21f49383aa9d2bdd9d243a6b to your computer and use it in GitHub Desktop.
Create a webhook for a github repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# this creates a github webhook that gets all events to a repository, useful with Jenkins Blue Ocean | |
service_url="https://my_url" | |
service_port="my_port" | |
organisation="" | |
repository="" | |
git_url="https://api.github.com/repos/${organisation}/${repository}/hooks" | |
auth_token="" # needs to have admin permissions for the repository | |
generate_post_data() | |
{ | |
cat <<EOF | |
{ | |
"name": "web", | |
"active": true, | |
"events": ["*"], | |
"config": { | |
"url": "${service_url}:${service_port}/github-webhook/", | |
"content_type": "application/x-www-form-urlencoded" | |
} | |
} | |
EOF | |
} | |
curl -H "Content-Type: application/x-www-form-urlencoded" \ | |
-H "Authorization: token ${auth_token}" \ | |
--data "$(generate_post_data)" \ | |
${git_url} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment