[Workflow] Try to fix code-formatter failing to find changes in some cases.
[llvm-project.git] / .github / workflows / pr-subscriber-wait.py
blob633f78c147707fc371dcd1dd156a1a6aae743012
1 import github
2 import os
3 import sys
4 import time
7 def needs_to_wait(repo):
8 workflow_name = os.environ.get("GITHUB_WORKFLOW")
9 run_number = os.environ.get("GITHUB_RUN_NUMBER")
10 print("Workflow Name:", workflow_name, "Run Number:", run_number)
11 for status in ["in_progress", "queued"]:
12 for workflow in repo.get_workflow_runs(status=status):
13 print("Looking at ", workflow.name, "#", workflow.run_number)
14 if workflow.name != workflow_name:
15 continue
16 if workflow.run_number < int(run_number):
17 print("Workflow {} still {} ".format(workflow.run_number, status))
18 return True
19 return False
22 repo_name = os.environ.get("GITHUB_REPOSITORY")
23 token = os.environ.get("GITHUB_TOKEN")
24 gh = github.Github(token)
25 repo = gh.get_repo(repo_name)
26 while needs_to_wait(repo):
27 time.sleep(30)