diff --git a/app/example_data.py b/app/example_data.py new file mode 100644 index 0000000..fdb7e44 --- /dev/null +++ b/app/example_data.py @@ -0,0 +1,178 @@ +res = { + "ref": "refs/heads/bx-test", + "before": "7680dd143e0c4faa05c5dbea822b247226d27490", + "after": "209d4b058850f04ce1ce29ead1509a072078605f", + "compare_url": "https://git.svs-tech.pro/ksenia_mikhailova/test-webhook/compare/7680dd143e0c4faa05c5dbea822b247226d27490...209d4b058850f04ce1ce29ead1509a072078605f", + "commits": [ + { + "id": "209d4b058850f04ce1ce29ead1509a072078605f", + "message": "test\n", + "url": "https://git.svs-tech.pro/ksenia_mikhailova/test-webhook/commit/209d4b058850f04ce1ce29ead1509a072078605f", + "author": { + "name": "aarizona", + "email": "ar.ariz.arizona@gmail.com", + "username": "", + }, + "committer": { + "name": "aarizona", + "email": "ar.ariz.arizona@gmail.com", + "username": "", + }, + "verification": None, + "timestamp": "2024-05-02T11:56:57+03:00", + "added": [], + "removed": [], + "modified": ["app/main.py"], + } + ], + "total_commits": 1, + "head_commit": { + "id": "209d4b058850f04ce1ce29ead1509a072078605f", + "message": "test\n", + "url": "https://git.svs-tech.pro/ksenia_mikhailova/test-webhook/commit/209d4b058850f04ce1ce29ead1509a072078605f", + "author": { + "name": "aarizona", + "email": "ar.ariz.arizona@gmail.com", + "username": "", + }, + "committer": { + "name": "aarizona", + "email": "ar.ariz.arizona@gmail.com", + "username": "", + }, + "verification": None, + "timestamp": "2024-05-02T11:56:57+03:00", + "added": [], + "removed": [], + "modified": ["app/main.py"], + }, + "repository": { + "id": 16, + "owner": { + "id": 5, + "login": "ksenia_mikhailova", + "login_name": "", + "full_name": "", + "email": "k.mikhailova@svs-tech.pro", + "avatar_url": "https://git.svs-tech.pro/avatar/656964d6d4fe71056017525a6d035721", + "language": "", + "is_admin": False, + "last_login": "0001-01-01T00:00:00Z", + "created": "2024-03-26T09:48:12+03:00", + "restricted": False, + "active": False, + "prohibit_login": False, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "ksenia_mikhailova", + }, + "name": "test-webhook", + "full_name": "ksenia_mikhailova/test-webhook", + "description": "", + "empty": False, + "private": False, + "fork": False, + "template": False, + "parent": None, + "mirror": False, + "size": 23, + "language": "", + "languages_url": "https://git.svs-tech.pro/api/v1/repos/ksenia_mikhailova/test-webhook/languages", + "html_url": "https://git.svs-tech.pro/ksenia_mikhailova/test-webhook", + "url": "https://git.svs-tech.pro/api/v1/repos/ksenia_mikhailova/test-webhook", + "link": "", + "ssh_url": "git@git.svs-tech.pro:ksenia_mikhailova/test-webhook.git", + "clone_url": "https://git.svs-tech.pro/ksenia_mikhailova/test-webhook.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "main", + "archived": False, + "created_at": "2024-05-02T11:12:56+03:00", + "updated_at": "2024-05-02T11:54:13+03:00", + "archived_at": "1970-01-01T03:00:00+03:00", + "permissions": {"admin": True, "push": True, "pull": True}, + "has_issues": True, + "internal_tracker": { + "enable_time_tracker": True, + "allow_only_contributors_to_track_time": True, + "enable_issue_dependencies": True, + }, + "has_wiki": True, + "has_pull_requests": True, + "has_projects": True, + "has_releases": True, + "has_packages": True, + "has_actions": False, + "ignore_whitespace_conflicts": False, + "allow_merge_commits": True, + "allow_rebase": True, + "allow_rebase_explicit": True, + "allow_squash_merge": True, + "allow_rebase_update": True, + "default_delete_branch_after_merge": False, + "default_merge_style": "merge", + "default_allow_maintainer_edit": False, + "avatar_url": "", + "internal": False, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": None, + }, + "pusher": { + "id": 5, + "login": "ksenia_mikhailova", + "login_name": "", + "full_name": "", + "email": "ksenia_mikhailova@noreply.localhost", + "avatar_url": "https://git.svs-tech.pro/avatar/656964d6d4fe71056017525a6d035721", + "language": "", + "is_admin": False, + "last_login": "0001-01-01T00:00:00Z", + "created": "2024-03-26T09:48:12+03:00", + "restricted": False, + "active": False, + "prohibit_login": False, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "ksenia_mikhailova", + }, + "sender": { + "id": 5, + "login": "ksenia_mikhailova", + "login_name": "", + "full_name": "", + "email": "ksenia_mikhailova@noreply.localhost", + "avatar_url": "https://git.svs-tech.pro/avatar/656964d6d4fe71056017525a6d035721", + "language": "", + "is_admin": False, + "last_login": "0001-01-01T00:00:00Z", + "created": "2024-03-26T09:48:12+03:00", + "restricted": False, + "active": False, + "prohibit_login": False, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "ksenia_mikhailova", + }, +} diff --git a/app/main.py b/app/main.py index 77b4bd4..6a78824 100644 --- a/app/main.py +++ b/app/main.py @@ -13,5 +13,8 @@ def read_root(): @app.post("/integration") async def intgr(request: Request): body = await request.json() - logger.info(body) + ref = body["ref"] + branch = ref.split('/')[-1] + [tag, number, *args] = branch.split('-') + logger.info(f"{tag} {number} {args}") return {"status": "success"}