|
18 | 18 |
|
19 | 19 | import conda_forge_webservices.linting as linting
|
20 | 20 | import conda_forge_webservices.status as status
|
| 21 | +import conda_forge_webservices.update_feedstocks as update_feedstocks |
21 | 22 | import conda_forge_webservices.update_teams as update_teams
|
22 | 23 | import conda_forge_webservices.commands as commands
|
23 | 24 |
|
@@ -108,6 +109,27 @@ def post(self):
|
108 | 109 | self.write_error(404)
|
109 | 110 |
|
110 | 111 |
|
| 112 | +class UpdateFeedstockHookHandler(tornado.web.RequestHandler): |
| 113 | + def post(self): |
| 114 | + headers = self.request.headers |
| 115 | + event = headers.get('X-GitHub-Event', None) |
| 116 | + |
| 117 | + if event == 'ping': |
| 118 | + self.write('pong') |
| 119 | + elif event == 'push': |
| 120 | + body = tornado.escape.json_decode(self.request.body) |
| 121 | + repo_name = body['repository']['name'] |
| 122 | + owner = body['repository']['owner']['login'] |
| 123 | + ref = body['ref'] |
| 124 | + # Only do anything if we are working with conda-forge, and a push to master. |
| 125 | + if owner == 'conda-forge' and ref == "refs/heads/master": |
| 126 | + update_feedstocks.update_feedstock(owner, repo_name) |
| 127 | + else: |
| 128 | + print('Unhandled event "{}".'.format(event)) |
| 129 | + self.set_status(404) |
| 130 | + self.write_error(404) |
| 131 | + |
| 132 | + |
111 | 133 | class UpdateTeamHookHandler(tornado.web.RequestHandler):
|
112 | 134 | def post(self):
|
113 | 135 | headers = self.request.headers
|
@@ -193,6 +215,7 @@ def create_webapp():
|
193 | 215 | application = tornado.web.Application([
|
194 | 216 | (r"/conda-linting/hook", LintingHookHandler),
|
195 | 217 | (r"/conda-forge-status/hook", StatusHookHandler),
|
| 218 | + (r"/conda-forge-feedstocks/hook", UpdateFeedstockHookHandler), |
196 | 219 | (r"/conda-forge-teams/hook", UpdateTeamHookHandler),
|
197 | 220 | (r"/conda-forge-command/hook", CommandHookHandler),
|
198 | 221 | ])
|
|
0 commit comments