def on_github_push(event, context, dryrun=False): message = _process_event(event) ref = message["ref"] secret_name = os.environ['SECRET_NAME'] secrets = json.loads(get_secret(secret_name)) access_token = get_access_token(secrets) service_account = get_service_account(secrets) if ref in BRANCH_REFS: repo_name = message["repository"]["full_name"] repo = Github(access_token).get_repo(repo_name) branch = repo.get_branch(ref) pusher = message["pusher"]["name"] notification_message = "Commit to " + ref + " detected on " + repo_name + " branch " + branch.name + " by " + \ pusher print(notification_message) _send_notification(notification_message, context, dryrun) server_path = 'json_schema' versions_file = repo.get_contents(server_path + "/versions.json", branch.name) version_numbers_str = base64.b64decode( versions_file.content).decode("utf-8") version_numbers = json.loads(version_numbers_str) result = _process_directory(repo, branch.name, server_path, server_path, version_numbers, context, dryrun) result_str = "\n".join(result) result_message = "" if len(result) == 0: result_message = result_message + "No schema changes published" else: result_message = result_message + "New schema changes published:\n" + result_str time.sleep(5) notify_ingest(branch.name, service_account) print(result_message) _send_notification(result_message, context, dryrun) else: result = [] response = {"statusCode": 200, "body": {"created": json.dumps(result)}} return response