-
-
Notifications
You must be signed in to change notification settings - Fork 777
/
get-timeline.js
35 lines (34 loc) · 1020 Bytes
/
get-timeline.js
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
/**
* Function that returns the timeline of an issue
* @param {Object} github - github object from actions/github-script
* @param {Object} context - context object from actions/github-script
* @param {Number} issueNum - the issue number
* @returns {Object} timelineArray - an array containing the timeline of issue events
*/
async function getTimeline(issueNum, github, context) {
let timelineArray = [];
let page = 1;
while (true) {
try {
const results = await github.rest.issues.listEventsForTimeline({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNum,
per_page: 100,
page: page,
});
if (results.data.length) {
timelineArray = timelineArray.concat(results.data);
} else {
break;
}
} catch (err) {
console.log(err);
continue;
} finally {
page++;
}
}
return timelineArray;
}
module.exports = getTimeline;