-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathutils.js
More file actions
58 lines (45 loc) · 1.24 KB
/
Copy pathutils.js
File metadata and controls
58 lines (45 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {getInput, info} from '@actions/core';
import {getOctokit} from '@actions/github';
import {retry} from '@octokit/plugin-retry';
import {throttling} from '@octokit/plugin-throttling';
import {schema} from './schema.js';
function getConfig() {
const input = Object.fromEntries(
Object.keys(schema.describe().keys).map(item => [item, getInput(item)])
);
const {error, value} = schema.validate(input, {abortEarly: false});
if (error) {
throw error;
}
return value;
}
function getClient(token) {
const requestRetries = 30;
const rateLimitCallback = function (
retryAfter,
options,
octokit,
retryCount
) {
info(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (retryCount < requestRetries) {
info(`Retrying after ${retryAfter} seconds`);
return true;
}
};
const options = {
request: {retries: requestRetries},
throttle: {
onSecondaryRateLimit: rateLimitCallback,
onRateLimit: rateLimitCallback
}
};
const octokit = getOctokit(token, options, retry, throttling);
octokit.request = octokit.request.defaults({
headers: {'X-GitHub-Api-Version': '2026-03-10'}
});
return octokit;
}
export {getConfig, getClient};