From 457f95d566cfe856756f2d8b74bd4b8b6f45840d Mon Sep 17 00:00:00 2001 From: ori Date: Wed, 11 Dec 2024 18:32:37 +0200 Subject: [PATCH] github pusher --- hasadna_k8s/github_pusher/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hasadna_k8s/github_pusher/main.py b/hasadna_k8s/github_pusher/main.py index bb88c38f..ce7c00a1 100644 --- a/hasadna_k8s/github_pusher/main.py +++ b/hasadna_k8s/github_pusher/main.py @@ -1,5 +1,6 @@ import os import time +import json import base64 import dataclasses @@ -48,6 +49,13 @@ def parse_config(config): raise Exception(f'Unknown config type: {config["type"]}') +def parse_configs(configs): + configs = [parse_config(config) for config in configs] + for config in configs: + print(config) + return configs + + def get_configs(): with open(GITHUB_PUSHER_CONFIG_YAML_PATH) as f: data = benedict(f.read(), format='yaml') @@ -121,7 +129,7 @@ def process(repository_name, repository_organization, ref, files, commit_context requests_options = {'headers': {'Authorization': f'token {get_github_token()}'}} with open(GITHUB_PUSHER_CONFIG_YAML_PATH) as f: data = benedict(f.read(), format='yaml', keypath_separator=None) - configs = [parse_config(config) for config in data['configs']] + configs = parse_configs(data['configs']) print(f'process {repository_organization}/{repository_name} {ref} ({",".join(files)}) {commit_context}') if ref.startswith('refs/heads/') and files: branch = ref.replace('refs/heads/', '') @@ -136,6 +144,7 @@ def process(repository_name, repository_organization, ref, files, commit_context def run(event): + print(json.dumps(event)) x_github_event = event.get('X-GitHub-Event') assert x_github_event == 'push', f'Unexpected X-GitHub-Event: {x_github_event}' repository_name = event.get('repository', {}).get('name')