|
@@ -0,0 +1,29 @@
|
|
1
|
+#!/usr/bin/env python3
|
|
2
|
+# Simple script to send test webhooks
|
|
3
|
+import sys
|
|
4
|
+import requests
|
|
5
|
+
|
|
6
|
+if len(sys.argv) != 2:
|
|
7
|
+ print("Provide name of webhook as argument")
|
|
8
|
+ sys.exit(1)
|
|
9
|
+
|
|
10
|
+webhook_type = sys.argv[1]
|
|
11
|
+
|
|
12
|
+try:
|
|
13
|
+ with open("./{}.json".format(webhook_type), "r") as f:
|
|
14
|
+ json = f.read()
|
|
15
|
+except FileNotFoundError:
|
|
16
|
+ print("Can't find {}.json".format(webhook_type))
|
|
17
|
+ sys.exit(1)
|
|
18
|
+
|
|
19
|
+url = "http://localhost:8045/github"
|
|
20
|
+print("Posting to {}...".format(url))
|
|
21
|
+
|
|
22
|
+res = requests.post(url, data=json, headers={"X-GitHub-Event": webhook_type})
|
|
23
|
+
|
|
24
|
+if res.status_code != 200:
|
|
25
|
+ print("Webhook error (status {}):".format(res.status_code))
|
|
26
|
+ print(res.text)
|
|
27
|
+ sys.exit(2)
|
|
28
|
+else:
|
|
29
|
+ print("Success!")
|