Use workflow names in approve lambda

This commit is contained in:
Mikhail f. Shiryaev 2022-01-19 17:00:41 +01:00
parent e6070b124b
commit 9cb136f5b0
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -6,8 +6,8 @@ import fnmatch
from collections import namedtuple from collections import namedtuple
import jwt import jwt
import requests import requests # type: ignore
import boto3 import boto3 # type: ignore
API_URL = "https://api.github.com/repos/ClickHouse/ClickHouse" API_URL = "https://api.github.com/repos/ClickHouse/ClickHouse"
@ -52,18 +52,19 @@ TRUSTED_ORG_IDS = {
54801242, # clickhouse 54801242, # clickhouse
} }
# See {API_URL}/actions/workflows # See https://api.github.com/repos/ClickHouse/ClickHouse/actions/workflows
# Use ID to not inject a malicious workflow
TRUSTED_WORKFLOW_IDS = { TRUSTED_WORKFLOW_IDS = {
14586616, # Cancel workflows, always trusted 14586616, # Cancel workflows, always trusted
} }
NEED_RERUN_WORKFLOWS = { NEED_RERUN_WORKFLOWS = {
14738810, # DocsRelease "BackportPR",
15834118, # Docs "Docs",
15522500, # MasterCI "DocsRelease",
15516108, # ReleaseCI "MasterCI",
15797242, # BackportPR "PullRequestCI",
16441423, # PullRequestCI "ReleaseCI",
} }
# Individual trusted contirbutors who are not in any trusted organization. # Individual trusted contirbutors who are not in any trusted organization.
@ -392,10 +393,10 @@ def main(event):
"completed and failed, let's check for rerun", "completed and failed, let's check for rerun",
) )
if workflow_description.workflow_id not in NEED_RERUN_WORKFLOWS: if workflow_description.name not in NEED_RERUN_WORKFLOWS:
print( print(
"Workflow", "Workflow",
workflow_description.workflow_id, workflow_description.name,
"not in list of rerunable workflows", "not in list of rerunable workflows",
) )
return return
@ -437,7 +438,8 @@ def main(event):
print(f"Totally have {len(changed_files)} changed files in PR:", changed_files) print(f"Totally have {len(changed_files)} changed files in PR:", changed_files)
if check_suspicious_changed_files(changed_files): if check_suspicious_changed_files(changed_files):
print( print(
f"Pull Request {pull_request['number']} has suspicious changes, label it for manuall approve" f"Pull Request {pull_request['number']} has suspicious changes, "
"label it for manuall approve"
) )
label_manual_approve(pull_request, token) label_manual_approve(pull_request, token)
else: else: