@@ -4,14 +4,25 @@ import moment from 'moment';
4
4
5
5
import { createGithubAppAuth , createGithubInstallationAuth , createOctokitClient } from '../github/auth' ;
6
6
import { bootTimeExceeded , listEC2Runners , tag , untag , terminateRunner } from './../aws/runners' ;
7
- import { RunnerInfo , RunnerList , RunnerState } from './../aws/runners.d' ;
7
+ import { RunnerInfo , RunnerList } from './../aws/runners.d' ;
8
8
import { GhRunners , githubCache } from './cache' ;
9
9
import { ScalingDownConfig , getEvictionStrategy , getIdleRunnerCount } from './scale-down-config' ;
10
10
import { metricGitHubAppRateLimit } from '../github/rate-limit' ;
11
11
import { getGitHubEnterpriseApiUrl } from './scale-up' ;
12
+ import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types/dist-types/GetResponseTypeFromEndpointMethod' ;
12
13
13
14
const logger = createChildLogger ( 'scale-down' ) ;
14
15
16
+ type OrgRunnerList = GetResponseDataTypeFromEndpointMethod <
17
+ typeof Octokit . prototype . actions . listSelfHostedRunnersForOrg
18
+ > ;
19
+
20
+ type RepoRunnerList = GetResponseDataTypeFromEndpointMethod <
21
+ typeof Octokit . prototype . actions . listSelfHostedRunnersForRepo
22
+ > ;
23
+
24
+ // Derive the shape of an individual runner
25
+ type RunnerState = ( OrgRunnerList | RepoRunnerList ) [ 'runners' ] [ number ] ;
15
26
16
27
async function getOrCreateOctokit ( runner : RunnerInfo ) : Promise < Octokit > {
17
28
const key = runner . owner ;
0 commit comments