Skip to content

Commit

Permalink
github pusher
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Dec 11, 2024
1 parent 31cc38f commit 457f95d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hasadna_k8s/github_pusher/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import time
import json
import base64
import dataclasses

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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/', '')
Expand All @@ -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')
Expand Down

0 comments on commit 457f95d

Please sign in to comment.