4
4
import os
5
5
6
6
import aiohttp
7
- from aiogithubapi import GitHub
7
+ from aiogithubapi import GitHub , GitHubAPI
8
8
from homeassistant .core import HomeAssistant
9
9
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
17
15
18
16
TOKEN = os .getenv ("INPUT_GITHUB_TOKEN" )
19
17
GITHUB_WORKSPACE = os .getenv ("GITHUB_WORKSPACE" )
@@ -111,7 +109,7 @@ async def preflight():
111
109
error ("No category found, use env CATEGORY to set this." )
112
110
113
111
async with aiohttp .ClientSession () as session :
114
- github = GitHub (TOKEN , session )
112
+ github = GitHub (TOKEN , session , headers = HACS_ACTION_GITHUB_API_HEADERS )
115
113
repo = await github .get_repo (repository )
116
114
if ref is None and GITHUB_REPOSITORY != "hacs/default" :
117
115
ref = repo .default_branch
@@ -122,15 +120,29 @@ async def preflight():
122
120
async def validate_repository (repository , category , ref = None ):
123
121
"""Validate."""
124
122
async with aiohttp .ClientSession () as session :
125
- hacs = get_hacs ()
123
+ hacs = HacsBase ()
126
124
hacs .hass = HomeAssistant ()
127
125
hacs .session = session
128
- hacs .configuration = Configuration ()
129
126
hacs .configuration .token = TOKEN
130
127
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
+ )
132
142
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
+ )
134
146
except HacsException as exception :
135
147
error (exception )
136
148
0 commit comments