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): ...@@ -33,15 +33,26 @@ def get_runs(trigger_phrase):
pr_runs = [] pr_runs = []
if environ.get("GITHUB_EVENT_NAME", "") == "pull_request": if environ.get("GITHUB_EVENT_NAME", "") == "pull_request":
pr_number = int(environ.get("GITHUB_REF").split('/')[-2]) pr_number = int(environ.get("GITHUB_REF").split('/')[-2])
req = request.Request(url="{}/repos/microsoft/LightGBM/issues/{}/comments".format(environ.get("GITHUB_API_URL"), page = 1
pr_number), while True:
headers={"Accept": "application/vnd.github.v3+json"}) req = request.Request(
url = request.urlopen(req) url="{}/repos/microsoft/LightGBM/issues/{}/comments?page={}&per_page=100".format(
data = json.loads(url.read().decode('utf-8')) environ.get("GITHUB_API_URL"),
url.close() pr_number,
pr_runs = [i for i in data page
if i['author_association'].lower() in {'owner', 'member', 'collaborator'} ),
and i['body'].startswith('/gha run {}'.format(trigger_phrase))] headers={"Accept": "application/vnd.github.v3+json"}
)
url = request.urlopen(req)
data = json.loads(url.read().decode('utf-8'))
url.close()
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] 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