fix hook
This commit is contained in:
parent
5ceb648dc9
commit
d18ac0baa6
|
@ -44,10 +44,8 @@ if {{cookiecutter.generate_gitea_project}}:
|
|||
repo = giteapy.CreateRepoOption(
|
||||
name="{{ cookiecutter.project_slug }}", private=True
|
||||
)
|
||||
api_instance.create_current_user_repo(repo)
|
||||
api_instance.create_current_user_repo(body=repo)
|
||||
|
||||
subprocess.call(["git", "remote", "add", "origin", "{{ cookiecutter.git_origin }}"])
|
||||
subprocess.call(["git", "push", "-u", "origin", "main"])
|
||||
|
||||
if {{cookiecutter.generate_gitea_project}} and {{cookiecutter.configure_ci}}:
|
||||
import http.client
|
||||
|
@ -60,14 +58,28 @@ if {{cookiecutter.generate_gitea_project}} and {{cookiecutter.configure_ci}}:
|
|||
"{{ cookiecutter.git_user }}",
|
||||
"{{ cookiecutter.project_slug }}",
|
||||
"{{ cookiecutter.woodpecker_gitea_user }}",
|
||||
options,
|
||||
body=options,
|
||||
)
|
||||
|
||||
API_KEY = get_secret("Woodpecker Token")
|
||||
WOODPECKER_SERVER = "{{ cookiecutter.woodpecker_server }}".removeprefix("https://")
|
||||
origin = "cookiecutter.git_origin"
|
||||
repo = "/".join(origin.removesuffix(".git").split("/")[-2:])
|
||||
origin = "{{ cookiecutter.git_origin }}"
|
||||
repo = "/".join(origin.removesuffix(".git").split(":")[-1].split("/")[-2:])
|
||||
connection = http.client.HTTPSConnection(WOODPECKER_SERVER)
|
||||
connection.request(
|
||||
"GET",
|
||||
"/api/user/repos?all=true&flush=true",
|
||||
headers={"Authorization": f"Bearer {API_KEY}"},
|
||||
)
|
||||
response = connection.getresponse()
|
||||
status = response.status
|
||||
response.read()
|
||||
if status != 200:
|
||||
print(
|
||||
f"\033[38;2;255;0;0mInvalid response from woodpecker while loading repos: {status} ({response.reason})\033[0m"
|
||||
)
|
||||
exit(1)
|
||||
|
||||
connection.request(
|
||||
"POST",
|
||||
f"/api/repos/{repo}",
|
||||
|
@ -78,6 +90,12 @@ if {{cookiecutter.generate_gitea_project}} and {{cookiecutter.configure_ci}}:
|
|||
)
|
||||
response = connection.getresponse()
|
||||
status = response.status
|
||||
# body = json.load(response)
|
||||
if status != 200:
|
||||
print(f"Invalid response: {status}")
|
||||
print(
|
||||
f"\033[38;2;255;0;0mInvalid response from woodpecker while linking repo: {status} ({response.reason})\033[0m"
|
||||
)
|
||||
exit(1)
|
||||
|
||||
if {{cookiecutter.generate_gitea_project}}:
|
||||
subprocess.call(["git", "remote", "add", "origin", "{{ cookiecutter.git_origin }}"])
|
||||
subprocess.call(["git", "push", "-u", "origin", "main"])
|
||||
|
|
Loading…
Reference in a new issue