mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
Fix pr_infos_url retrieval
This commit is contained in:
parent
90b4a06e64
commit
84c6eb1a2a
1 changed files with 9 additions and 6 deletions
15
run.py
15
run.py
|
@ -1048,7 +1048,8 @@ async def github(request):
|
||||||
if not await is_user_in_organization(hook_infos["comment"]["user"]["login"]):
|
if not await is_user_in_organization(hook_infos["comment"]["user"]["login"]):
|
||||||
# Unauthorized
|
# Unauthorized
|
||||||
abort(403, "Unauthorized")
|
abort(403, "Unauthorized")
|
||||||
type = "issue"
|
# Fetch the PR infos (yeah they ain't in the initial infos we get @_@)
|
||||||
|
pr_infos_url = hook_infos["issue"]["pull_request"]["url"]
|
||||||
|
|
||||||
elif hook_type == "pull_request":
|
elif hook_type == "pull_request":
|
||||||
if hook_infos["action"] != "opened":
|
if hook_infos["action"] != "opened":
|
||||||
|
@ -1058,13 +1059,13 @@ async def github(request):
|
||||||
if hook_infos["pull_request"]["user"]["login"] != "github-actions[bot]":
|
if hook_infos["pull_request"]["user"]["login"] != "github-actions[bot]":
|
||||||
# Unauthorized
|
# Unauthorized
|
||||||
abort(403, "Unauthorized")
|
abort(403, "Unauthorized")
|
||||||
type = "pull_request"
|
# Fetch the PR infos (yeah they ain't in the initial infos we get @_@)
|
||||||
|
pr_infos_url = hook_infos["pull_request"]["url"]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Nothing to do but success anyway (204 = No content)
|
# Nothing to do but success anyway (204 = No content)
|
||||||
abort(204, "Nothing to do")
|
abort(204, "Nothing to do")
|
||||||
|
|
||||||
# Fetch the PR infos (yeah they ain't in the initial infos we get @_@)
|
|
||||||
pr_infos_url = hook_infos[type]["url"]
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(pr_infos_url) as resp:
|
async with session.get(pr_infos_url) as resp:
|
||||||
pr_infos = await resp.json()
|
pr_infos = await resp.json()
|
||||||
|
@ -1089,8 +1090,10 @@ async def github(request):
|
||||||
# Answer with comment with link+badge for the job
|
# Answer with comment with link+badge for the job
|
||||||
|
|
||||||
async def comment(body):
|
async def comment(body):
|
||||||
|
if hook_type == "issue_comment":
|
||||||
comments_url = hook_infos[type]["comments_url"]
|
comments_url = hook_infos["issue"]["comments_url"]
|
||||||
|
else:
|
||||||
|
comments_url = hook_infos["pull_request"]["comments_url"]
|
||||||
|
|
||||||
token = open("./github_bot_token").read().strip()
|
token = open("./github_bot_token").read().strip()
|
||||||
async with aiohttp.ClientSession(headers={"Authorization": f"token {token}"}) as session:
|
async with aiohttp.ClientSession(headers={"Authorization": f"token {token}"}) as session:
|
||||||
|
|
Loading…
Add table
Reference in a new issue