Skip to content

Instantly share code, notes, and snippets.

@chetbox
Last active January 20, 2016 12:21
Show Gist options
  • Save chetbox/6dff213f4c07508a57ba to your computer and use it in GitHub Desktop.
Save chetbox/6dff213f4c07508a57ba to your computer and use it in GitHub Desktop.
Docker Hub webhook (PHP)

Docker Hub deploy webhook

A ghetto webhook for automatically deploying after a Docker Hub build.

Install (Ubuntu)

sudo apt-get install php-cli

Run

php -S 0.0.0.0:8000
<!DOCTYPE html>
<html>
<body>
<pre>
<?php
$trigger_tag = "master";
$post_data = json_decode($HTTP_RAW_POST_DATA, true);
$tag = $post_data["push_data"]["tag"];
if ($tag === $trigger_tag) {
$image = "user/repo:" . $trigger_tag;
echo `docker pull "$image"`;
echo `deploy_my_server.sh`;
} else {
echo "Ignoring tag " . $tag;
}
?>
</pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment