recognize org webhook ping
authorMichael Wallner <mike@php.net>
Mon, 5 Oct 2015 09:08:36 +0000 (11:08 +0200)
committerMichael Wallner <mike@php.net>
Mon, 5 Oct 2015 09:08:36 +0000 (11:08 +0200)
mirror.php

index f83eedf2ecd36e747c4b948e5ebab9dfc642bca9..3b71ef0a70596314b07d58843498e80ad70ed5e4 100644 (file)
@@ -42,6 +42,10 @@ switch ($evt) {
                        $response->setResponseCode(415);
                        $response->setContentType($request->getHeader("Content-Type"));
                        $response->getBody()->append($request->getBody());
+               } elseif (!isset($json->repository) && $evt === "ping") {
+                       // ping on an org webhook
+                       $response->setResponseCode(202);
+                       $response->getBody()->append("PONG");
                } elseif (!in_array(isset($json->repository->owner->name)?$json->repository->owner->name:$json->repository->owner->login, $owners, true)) {
                        $response->setResponseCode(403);
                        $response->getBody()->append("Invalid owner");