Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added php webhook

  • Loading branch information...
commit 4b870ff7f2640b83ba748e28e9d53d6ef91cb21d 1 parent fc9252e
@thousandsofthem thousandsofthem authored
View
18 php/github_webhook/README.md
@@ -0,0 +1,18 @@
+# Github Webhook Worker
+
+This shows how to kick off a worker from a webhook. This example uses Github's Service Hooks.
+
+## Getting started
+
+- Download and put `iron.json` in current directory [more info](http://dev.iron.io/worker/reference/configuration/)
+- Upload webhook via [CLI](http://dev.iron.io/worker/reference/cli/) tool: `iron_worker upload github_webhook`
+- Go to Github Service Hooks: github.com -> repository -> admin -> Service Hooks -> WebHook URLs
+- Assemble webhook url:
+```
+https://worker-aws-us-east-1.iron.io/2/projects/<project_id>/tasks/webhook?code_name=GithubWebHook&oauth=<token>"
+```
+Where `<project_id>` and `<token>`are same as `iron.json` contain, `GithubWebHook` is name of your worker
+- Enter webhook url
+- Click Update Settings
+- Click Test Hook
+- Check the worker status and logs in IronWorker at http://hud.iron.io to ensure it ran successfully.
View
15 php/github_webhook/github_webhook.php
@@ -0,0 +1,15 @@
+<?php
+
+# the payload we get from github needs to be decoded first
+$payload_raw = getPayload();
+parse_str($payload_raw, $payload);
+echo "Payload:";
+print_r($payload);
+
+# Then we can parse the json
+$data = json_decode($payload['payload'], true);
+echo "data:";
+print_r($data);
+
+
+# Do something exciting here
View
3  php/github_webhook/github_webhook.worker
@@ -0,0 +1,3 @@
+name 'GithubWebHook'
+runtime 'php'
+exec 'github_webhook.php'
Please sign in to comment.
Something went wrong with that request. Please try again.