mirror of
https://gitlab.com/itsulu-odoo/runboat.git
synced 2026-05-30 23:41:27 +00:00
Ignore and log GitHub commit status creation errors
This commit is contained in:
parent
02d7fafb21
commit
9051373653
1 changed files with 18 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
|
|
@ -7,6 +8,8 @@ from pydantic import BaseModel, validator
|
|||
from .exceptions import NotFoundOnGitHub
|
||||
from .settings import settings
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _github_request(method: str, url: str, json: Any = None) -> Any:
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
|
@ -67,12 +70,18 @@ async def notify_status(
|
|||
if settings.disable_commit_statuses:
|
||||
return
|
||||
# https://docs.github.com/en/rest/reference/repos#create-a-commit-status
|
||||
await _github_request(
|
||||
"POST",
|
||||
f"/repos/{repo}/statuses/{sha}",
|
||||
json={
|
||||
"state": state,
|
||||
"target_url": target_url,
|
||||
"context": "runboat/build",
|
||||
},
|
||||
)
|
||||
try:
|
||||
await _github_request(
|
||||
"POST",
|
||||
f"/repos/{repo}/statuses/{sha}",
|
||||
json={
|
||||
"state": state,
|
||||
"target_url": target_url,
|
||||
"context": "runboat/build",
|
||||
},
|
||||
)
|
||||
except httpx.HTTPStatusError as e:
|
||||
_logger.error(
|
||||
f"Failed to post GitHub commit status (code {e.response.status_code}):\n"
|
||||
f"{e.response.text}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue