not-lain commited on
Commit
f8f713b
1 Parent(s): ecd8caa

check if a payload is a comment by the owner on an open pr

Browse files
Files changed (1) hide show
  1. src/gradio_space_ci/webhook.py +12 -0
src/gradio_space_ci/webhook.py CHANGED
@@ -283,6 +283,18 @@ async def trigger_ci_on_pr(payload: WebhookPayload, task_queue: BackgroundTasks)
283
  # Found a PR that is not yet synced
284
  task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
285
  has_task = True
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  if has_task:
288
  return Response("Task scheduled to sync/delete Space", status_code=status.HTTP_202_ACCEPTED)
 
283
  # Found a PR that is not yet synced
284
  task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
285
  has_task = True
286
+ if (
287
+ # Comment on an open pr by owner
288
+ payload.event.scope == "discussion.comment"
289
+ and payload.event.action == "create"
290
+ and payload.discussion.isPullRequest
291
+ and payload.discussion.status == "open"
292
+ # TODO:
293
+ # this limited to owner only
294
+ # check if it works with organizations
295
+ and payload.discussion.author.id == payload.repo.owner
296
+ ):
297
+ print(payload.comment.content)
298
 
299
  if has_task:
300
  return Response("Task scheduled to sync/delete Space", status_code=status.HTTP_202_ACCEPTED)