Add early exit on freshly opened PR to not process labels

This commit is contained in:
Mikhail f. Shiryaev 2023-01-31 13:56:00 +01:00
parent cd2e1cfada
commit cbbef49e9a
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -304,6 +304,12 @@ def main(event):
pull_request = event_data["pull_request"] pull_request = event_data["pull_request"]
labels = {label["name"] for label in pull_request["labels"]} labels = {label["name"] for label in pull_request["labels"]}
print("PR has labels", labels) print("PR has labels", labels)
if action == "opened" or (
action == "labeled" and pull_request["created_at"] == pull_request["updated_at"]
):
print("Freshly opened PR, nothing to do")
return
if action == "closed" or (action == "labeled" and "do not test" in labels): if action == "closed" or (action == "labeled" and "do not test" in labels):
print("PR merged/closed or manually labeled 'do not test' will kill workflows") print("PR merged/closed or manually labeled 'do not test' will kill workflows")
workflow_descriptions = get_workflows_description_for_pull_request( workflow_descriptions = get_workflows_description_for_pull_request(