3zadania/create_issue.py
2026-05-05 19:46:10 +03:00

33 lines
813 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
import requests
TOKEN = os.getenv("GITEA_WRITE_TOKEN")
if not TOKEN:
raise Exception("Переменная окружения GITEA_WRITE_TOKEN не задана")
headers = {
"Authorization": f"token {TOKEN}",
"Content-Type": "application/json"
}
owner = "stud203834"
repo = "2zadanie"
url = f"https://git.vyatsu.ru/api/v1/repos/{owner}/{repo}/issues"
data = {
"title": "Тестовый issue от студента",
"body": "Создано через API Gitea с токеном на запись.",
"labels": []
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print("✅ Issue создан:")
print(response.json()["html_url"])
else:
print("❌ Ошибка:", response.status_code)
print(response.text)