Compare commits
2
Commits
test
..
43e4b9788a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43e4b9788a | ||
|
|
84b409356b |
+19
-8
@@ -39,18 +39,19 @@ async def test(request: Request):
|
||||
@app.post('/event')
|
||||
def handle_event(request: GiteaRequest):
|
||||
""" Handle event from webhook. """
|
||||
# stop early if asked
|
||||
# extract information
|
||||
commit_msg = request.head_commit['message']
|
||||
repo_url = request.repository['clone_url']
|
||||
branch_name = request.ref.split('/')[-1]
|
||||
logging.debug()
|
||||
# stop early if asked
|
||||
if commit_msg.lower().startswith('[skip ci]'):
|
||||
raise HTTPException(
|
||||
status_code=200,
|
||||
detail='skipping ci'
|
||||
)
|
||||
# clone repository
|
||||
repo_url = request.repository['clone_url']
|
||||
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():
|
||||
@@ -58,11 +59,21 @@ def handle_event(request: GiteaRequest):
|
||||
status_code=200,
|
||||
detail="no runner_script.yml in repository root"
|
||||
)
|
||||
# load runner commands
|
||||
# load runner script
|
||||
runner_script = load_runner_script(path=runner_script_path)
|
||||
for pipeline_name, pipeline_step in runner_script.pipelines.items():
|
||||
print(pipeline_name)
|
||||
print(pipeline_step)
|
||||
# determine pipeline to run
|
||||
if branch_name not in runner_script.pipelines.keys():
|
||||
# run default
|
||||
if 'default' not in runner_script.pipelines.keys():
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail='no pipelines defined in runner_script.yml'
|
||||
)
|
||||
pipeline = runner_script.pipelines['default']
|
||||
else:
|
||||
# run custom
|
||||
pipeline = runner_script.pipelines[branch_name]
|
||||
print(pipeline)
|
||||
|
||||
# send response
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user