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
import jwt
import requests
import boto3
import requests # type: ignore
import boto3 # type: ignore
API_URL = "https://api.github.com/repos/ClickHouse/ClickHouse"
@ -52,18 +52,19 @@ TRUSTED_ORG_IDS = {
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 = {
14586616, # Cancel workflows, always trusted
}
NEED_RERUN_WORKFLOWS = {
14738810, # DocsRelease
15834118, # Docs
15522500, # MasterCI
15516108, # ReleaseCI
15797242, # BackportPR
16441423, # PullRequestCI
"BackportPR",
"Docs",
"DocsRelease",
"MasterCI",
"PullRequestCI",
"ReleaseCI",
}
# 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",
)
if workflow_description.workflow_id not in NEED_RERUN_WORKFLOWS:
if workflow_description.name not in NEED_RERUN_WORKFLOWS:
print(
"Workflow",
workflow_description.workflow_id,
workflow_description.name,
"not in list of rerunable workflows",
)
return
@ -437,7 +438,8 @@ def main(event):
print(f"Totally have {len(changed_files)} changed files in PR:", changed_files)
if check_suspicious_changed_files(changed_files):
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)
else: