44import os
55
66import aiohttp
7- from aiogithubapi import GitHub
7+ from aiogithubapi import GitHub , GitHubAPI
88from homeassistant .core import HomeAssistant
99
10- from custom_components .hacs .hacsbase .configuration import Configuration
11- from custom_components .hacs .helpers .classes .exceptions import HacsException
12- from custom_components .hacs .helpers .functions .logger import getLogger
13- from custom_components .hacs .helpers .functions .register_repository import (
14- register_repository ,
15- )
16- from custom_components .hacs .share import get_hacs
10+ from custom_components .hacs .base import HacsBase
11+ from custom_components .hacs .const import HACS_ACTION_GITHUB_API_HEADERS
12+ from custom_components .hacs .exceptions import HacsException
13+ from custom_components .hacs .utils .logger import getLogger
14+ from custom_components .hacs .validate .manager import ValidationManager
1715
1816TOKEN = os .getenv ("INPUT_GITHUB_TOKEN" )
1917GITHUB_WORKSPACE = os .getenv ("GITHUB_WORKSPACE" )
@@ -111,7 +109,7 @@ async def preflight():
111109 error ("No category found, use env CATEGORY to set this." )
112110
113111 async with aiohttp .ClientSession () as session :
114- github = GitHub (TOKEN , session )
112+ github = GitHub (TOKEN , session , headers = HACS_ACTION_GITHUB_API_HEADERS )
115113 repo = await github .get_repo (repository )
116114 if ref is None and GITHUB_REPOSITORY != "hacs/default" :
117115 ref = repo .default_branch
@@ -122,15 +120,29 @@ async def preflight():
122120async def validate_repository (repository , category , ref = None ):
123121 """Validate."""
124122 async with aiohttp .ClientSession () as session :
125- hacs = get_hacs ()
123+ hacs = HacsBase ()
126124 hacs .hass = HomeAssistant ()
127125 hacs .session = session
128- hacs .configuration = Configuration ()
129126 hacs .configuration .token = TOKEN
130127 hacs .core .config_path = None
131- hacs .github = GitHub (hacs .configuration .token , hacs .session )
128+ hacs .validation = ValidationManager (hacs = hacs , hass = hacs .hass )
129+ ## Legacy GitHub client
130+ hacs .github = GitHub (
131+ hacs .configuration .token ,
132+ session ,
133+ headers = HACS_ACTION_GITHUB_API_HEADERS ,
134+ )
135+
136+ ## New GitHub client
137+ hacs .githubapi = GitHubAPI (
138+ token = hacs .configuration .token ,
139+ session = session ,
140+ ** {"client_name" : "HACS/Action" },
141+ )
132142 try :
133- await register_repository (repository , category , ref = ref )
143+ await hacs .async_register_repository (
144+ repository_full_name = repository , category = category , ref = ref
145+ )
134146 except HacsException as exception :
135147 error (exception )
136148
0 commit comments