Unverified Commit 06e3c4a9 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] fix getting status of optional workflows in PRs with a lot of comments (#4806)

* Update get_workflow_status.py

* Update get_workflow_status.py
parent b0137deb
......@@ -33,15 +33,26 @@ def get_runs(trigger_phrase):
pr_runs = []
if environ.get("GITHUB_EVENT_NAME", "") == "pull_request":
pr_number = int(environ.get("GITHUB_REF").split('/')[-2])
req = request.Request(url="{}/repos/microsoft/LightGBM/issues/{}/comments".format(environ.get("GITHUB_API_URL"),
pr_number),
headers={"Accept": "application/vnd.github.v3+json"})
page = 1
while True:
req = request.Request(
url="{}/repos/microsoft/LightGBM/issues/{}/comments?page={}&per_page=100".format(
environ.get("GITHUB_API_URL"),
pr_number,
page
),
headers={"Accept": "application/vnd.github.v3+json"}
)
url = request.urlopen(req)
data = json.loads(url.read().decode('utf-8'))
url.close()
pr_runs = [i for i in data
if not data:
break
runs_on_page = [i for i in data
if i['author_association'].lower() in {'owner', 'member', 'collaborator'}
and i['body'].startswith('/gha run {}'.format(trigger_phrase))]
pr_runs.extend(runs_on_page)
page += 1
return pr_runs[::-1]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment