@@ -157,7 +157,7 @@ public static async Task<bool> RemoveRunnerFromRepo(string repoName, string orgG
157157
158158 }
159159
160- public static async Task < GitHubJob > GetJobInfo ( long stuckJobGithubJobId , string repoName , string orgGitHubToken )
160+ public static async Task < GitHubJob > GetJobInfoForOrg ( long stuckJobGithubJobId , string repoName , string orgGitHubToken )
161161 {
162162 using HttpClient client = new ( ) ;
163163 client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/vnd.github+json" ) ) ;
@@ -176,6 +176,27 @@ public static async Task<GitHubJob> GetJobInfo(long stuckJobGithubJobId,string r
176176 }
177177 Log . Warning ( $ "Unable to get GH job info for { repoName } /{ stuckJobGithubJobId } : [{ response . StatusCode } ] { response . ReasonPhrase } ") ;
178178
179+ return null ;
180+ }
181+ public static async Task < GitHubJob > GetJobInfoForRepo ( long stuckJobGithubJobId , string repoName , string orgGitHubToken )
182+ {
183+ using HttpClient client = new ( ) ;
184+ client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/vnd.github+json" ) ) ;
185+ client . DefaultRequestHeaders . Add ( "X-GitHub-Api-Version" , "2022-11-28" ) ;
186+ client . DefaultRequestHeaders . Authorization = AuthenticationHeaderValue . Parse ( $ "Bearer { orgGitHubToken } ") ;
187+ client . DefaultRequestHeaders . UserAgent . Add ( new ProductInfoHeaderValue ( "hetzner-autoscale" , "1" ) ) ;
188+
189+ HttpResponseMessage response = await client . GetAsync (
190+ $ "https://api.github.com/repos/{ repoName } /actions/jobs/{ stuckJobGithubJobId } ") ;
191+ if ( response . IsSuccessStatusCode )
192+ {
193+ string content = await response . Content . ReadAsStringAsync ( ) ;
194+ GitHubJob responseObject = JsonSerializer . Deserialize < GitHubJob > ( content ) ;
195+
196+ return responseObject ;
197+ }
198+ Log . Warning ( $ "Unable to get GH job info for { repoName } /{ stuckJobGithubJobId } : [{ response . StatusCode } ] { response . ReasonPhrase } ") ;
199+
179200 return null ;
180201 }
181202}
0 commit comments