SharathReddy commited on
Commit
c710fcc
·
verified ·
1 Parent(s): 63843df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -113,19 +113,23 @@ async def github_webhook(request: Request):
113
  installation_id = payload["installation"]["id"]
114
  print(f"New installation created! ID: {installation_id}")
115
 
116
- # Get an access token for this installation
117
  try:
118
  token = get_installation_access_token(installation_id, GITHUB_APP_ID, GITHUB_PRIVATE_KEY)
119
 
120
- # Process all repositories this app was installed on
121
- for repo in payload["repositories"]:
122
  repo_full_name = repo["full_name"]
123
- repo_url = repo["html_url"]
124
- process_repository(repo_url, token, repo_full_name)
125
-
 
 
 
 
 
126
  except Exception as e:
127
  print(f"Error during installation processing: {e}")
128
- raise HTTPException(status_code=500, detail="Failed to process installation.")
129
 
130
  elif event_type == "push":
131
  pusher = payload.get("pusher", {}).get("name")
 
113
  installation_id = payload["installation"]["id"]
114
  print(f"New installation created! ID: {installation_id}")
115
 
 
116
  try:
117
  token = get_installation_access_token(installation_id, GITHUB_APP_ID, GITHUB_PRIVATE_KEY)
118
 
119
+ # The key in the payload is "repositories_added" for this event
120
+ for repo in payload.get("repositories_added", []):
121
  repo_full_name = repo["full_name"]
122
+ # The correct key for the git URL is 'clone_url'
123
+ repo_url = repo.get("clone_url") # <--- THIS IS THE FIX
124
+
125
+ if repo_url:
126
+ process_repository(repo_url, token, repo_full_name)
127
+ else:
128
+ print(f"Could not find 'clone_url' for repo {repo_full_name}")
129
+
130
  except Exception as e:
131
  print(f"Error during installation processing: {e}")
132
+ raise HTTPException(status_code=500, detail=f"Failed to process installation: {e}")
133
 
134
  elif event_type == "push":
135
  pusher = payload.get("pusher", {}).get("name")