mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Trying to use push event
This commit is contained in:
parent
48dfd44727
commit
589bb9eb92
8
.github/workflows/release_branches.yml
vendored
8
.github/workflows/release_branches.yml
vendored
@ -1,17 +1,12 @@
|
||||
name: ReleaseCI
|
||||
on: # yamllint disable-line rule:truthy
|
||||
pull_request:
|
||||
branches:
|
||||
- '21.**'
|
||||
- '22.**'
|
||||
- '23.**'
|
||||
- '24.**'
|
||||
push:
|
||||
branches:
|
||||
- '21.**'
|
||||
- '22.**'
|
||||
- '23.**'
|
||||
- '24.**'
|
||||
- 'backport/**'
|
||||
jobs:
|
||||
DockerHubPush:
|
||||
runs-on: [self-hosted, style-checker]
|
||||
@ -94,7 +89,6 @@ jobs:
|
||||
docker kill $(docker ps -q) ||:
|
||||
docker rm -f $(docker ps -a -q) ||:
|
||||
sudo rm -fr $TEMP_PATH
|
||||
|
||||
BuilderDebAsan:
|
||||
needs: [DockerHubPush]
|
||||
runs-on: [self-hosted, builder]
|
||||
|
@ -8,6 +8,23 @@ from unidiff import PatchSet
|
||||
|
||||
DIFF_IN_DOCUMENTATION_EXT = [".html", ".md", ".yml", ".txt", ".css", ".js", ".xml", ".ico", ".conf", ".svg", ".png", ".jpg", ".py", ".sh"]
|
||||
|
||||
def get_pr_for_commit(sha):
|
||||
try_get_pr_url = f"https://api.github.com/repos/{os.getenv('GITHUB_REPOSITORY', 'ClickHouse/ClickHouse')}/commits/{sha}/pulls"
|
||||
try:
|
||||
response = requests.get(try_get_pr_url)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
if len(data) > 1:
|
||||
print("Got more than one pr for commit", sha)
|
||||
for pr in data:
|
||||
if 'release' in {label['name'] for label in pr['labels']}:
|
||||
return pr
|
||||
first_pr = data[0]
|
||||
return first_pr
|
||||
except Exception as ex:
|
||||
print("Cannot fetch PR info from commit", ex)
|
||||
return None
|
||||
|
||||
class PRInfo:
|
||||
def __init__(self, github_event, need_orgs=False, need_changed_files=False):
|
||||
if 'pull_request' in github_event: # pull request and other similar events
|
||||
@ -46,22 +63,32 @@ class PRInfo:
|
||||
self.changed_files = { f.path for f in diff_object }
|
||||
|
||||
elif 'commits' in github_event:
|
||||
self.number = 0
|
||||
self.sha = github_event['after']
|
||||
self.labels = {}
|
||||
self.repo_full_name = os.getenv('GITHUB_REPOSITORY', 'ClickHouse/ClickHouse')
|
||||
pull_request = get_pr_for_commit(self.sha)
|
||||
repo_prefix = f"{os.getenv('GITHUB_SERVER_URL', 'https://github.com')}/{os.getenv('GITHUB_REPOSITORY', 'ClickHouse/ClickHouse')}"
|
||||
self.task_url = f"{repo_prefix}/actions/runs/{os.getenv('GITHUB_RUN_ID')}"
|
||||
self.commit_html_url = f"{repo_prefix}/commits/{self.sha}"
|
||||
self.pr_html_url = f"{repo_prefix}/commits/master"
|
||||
self.base_ref = "master"
|
||||
self.base_name = self.repo_full_name
|
||||
self.head_ref = "master"
|
||||
self.head_name = self.repo_full_name
|
||||
self.repo_full_name = os.getenv('GITHUB_REPOSITORY', 'ClickHouse/ClickHouse')
|
||||
if pull_request is None or pull_request['state'] == 'closed': # it's merged PR to master
|
||||
self.number = 0
|
||||
self.labels = {}
|
||||
self.pr_html_url = f"{repo_prefix}/commits/master"
|
||||
self.base_ref = "master"
|
||||
self.base_name = self.repo_full_name
|
||||
self.head_ref = "master"
|
||||
self.head_name = self.repo_full_name
|
||||
else:
|
||||
self.number = pull_request['number']
|
||||
self.labels = { l['name'] for l in pull_request['labels'] }
|
||||
self.base_ref = pull_request['base']['ref']
|
||||
self.base_name = pull_request['base']['repo']['full_name']
|
||||
self.head_ref = pull_request['head']['ref']
|
||||
self.head_name = pull_request['head']['repo']['full_name']
|
||||
self.pr_html_url = pull_request['html_url']
|
||||
|
||||
if need_changed_files:
|
||||
commit_before = github_event['before']
|
||||
response = requests.get(f"{os.getenv('GITHUB_SERVER_URL')}/repos/{os.getenv('GITHUB_REPOSITORY')}/compare/{commit_before}...{self.sha}")
|
||||
response = requests.get(f"https://api.github.com/repos/{os.getenv('GITHUB_REPOSITORY')}/compare/{commit_before}...{self.sha}")
|
||||
response.raise_for_status()
|
||||
diff = response.json()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user