practice03-api-mamaev/git_create_repo.py

31 lines
826 B
Python

import os
import requests
def main():
token = os.environ.get("GIT_VYATSU_TOKEN_WRITE")
if not token:
raise RuntimeError("Переменная окружения GIT_VYATSU_TOKEN_WRITE не установлена")
headers = {
"Authorization": f"token {token}",
"Content-Type": "application/json"
}
data = {
"name": "practice03-api-mamaev",
"description": "Репозиторий создан через API Gitea для лабораторной работы",
"private": False,
"auto_init": True
}
response = requests.post(
"https://git.vyatsu.ru/api/v1/user/repos",
headers=headers,
json=data
)
print("Status code:", response.status_code)
print(response.json())
if __name__ == "__main__":
main()