derek-thomas HF staff commited on
Commit
d0819c0
1 Parent(s): c533979

Adding check to only operate on main

Browse files
Files changed (2) hide show
  1. app.py +6 -0
  2. requirements.txt +1 -1
app.py CHANGED
@@ -72,6 +72,12 @@ app = WebhooksServer(ui=ui.queue(), webhook_secret=WEBHOOK_SECRET)
72
  async def community(payload: WebhookPayload, task_queue: BackgroundTasks):
73
  if not payload.event.scope.startswith("repo"):
74
  return Response("No task scheduled", status_code=status.HTTP_200_OK)
 
 
 
 
 
 
75
 
76
  logger.info(f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}")
77
  task_queue.add_task(_process_webhook, payload=payload)
 
72
  async def community(payload: WebhookPayload, task_queue: BackgroundTasks):
73
  if not payload.event.scope.startswith("repo"):
74
  return Response("No task scheduled", status_code=status.HTTP_200_OK)
75
+ # Only run if change is on main branch
76
+ try:
77
+ if payload.updatedRefs[0].ref != 'refs/heads/main':
78
+ return Response("No task scheduled", status_code=status.HTTP_200_OK)
79
+ except:
80
+ return Response("No task scheduled", status_code=status.HTTP_200_OK)
81
 
82
  logger.info(f"Webhook received from {payload.repo.name} indicating a repo {payload.event.action}")
83
  task_queue.add_task(_process_webhook, payload=payload)
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  aiohttp==3.8.3
2
  datasets==2.18.0
3
- huggingface-hub>=0.20.0
4
  pandas==1.5.3
5
  requests==2.31.0
6
  tqdm==4.66.1
 
1
  aiohttp==3.8.3
2
  datasets==2.18.0
3
+ huggingface-hub==0.23.1
4
  pandas==1.5.3
5
  requests==2.31.0
6
  tqdm==4.66.1