From 9fffa861e7909fb1645837b3060fd71ef3adcfc4 Mon Sep 17 00:00:00 2001 From: brb Date: Thu, 6 Jul 2023 13:10:13 +0200 Subject: [PATCH] added checking for presence of runner script --- code/app.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/app.py b/code/app.py index ae9fe65..f3e0af9 100644 --- a/code/app.py +++ b/code/app.py @@ -27,7 +27,7 @@ async def test(request: Request): @app.post('/event') def handle_event(request: GiteaRequest): """ Handle event from webhook. """ - # stop early if allowed + # stop early if asked commit_msg = request.head_commit['message'] if commit_msg.lower().startswith('[skip ci]'): raise HTTPException( @@ -39,6 +39,15 @@ def handle_event(request: GiteaRequest): logging.info('cloning repository: {repo_url}') local_repo_dir = clone_repository(repo_url) logging.info(f'local_repo_dir: {local_repo_dir}') + # locate runner script + runner_script_path = local_repo_dir / 'runner_script.yml' + if not runner_script_path.exists(): + raise HTTPException( + status_code=200, + detail='no "runner_script.yml" in repository root' + ) + + # send response raise HTTPException( status_code=202, detail='received task'