Skip to content

Commit 8888a04

Browse files
committed
update
1 parent a6f30c6 commit 8888a04

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/actions/list-pr/action.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ inputs:
1818
hours:
1919
description: 'Pull requests created within this many hours will be listed'
2020
required: false
21-
default: ''
21+
default: '24'
2222
outputs:
2323
result:
2424
description: 'Pull requests to be listed'
@@ -46,10 +46,27 @@ runs:
4646
}
4747
);
4848
49-
const pr_numbers = resp.data.map(pr => pr.number);
50-
core.info(`prs: ${pr_numbers.join(",")}`);
49+
const timeRange = parseInt(${{ inputs.hours }}) * 60 * 60 * 1000;
50+
const sinceTime = new Date(Date.now() - timeRange).toISOString();
51+
const input_labels = ${{ inputs.labels }};
52+
const labels = input_labels
53+
? input_labels.split(',|\n').map(label => label.trim())
54+
: [];
55+
56+
const prs = resp.data.filter(pr => {
57+
const hasLabel = labels.length === 0
58+
|| labels.every(label => pr.labels.some(prLabel => prLabel.name === label));
59+
60+
const createdAt = new Date(pr.created_at);
61+
const isWithinTimeRange = createdAt >= new Date(sinceTime);
62+
63+
return hasLabel && isWithinTimeRange;
64+
});
65+
66+
const pr_urls = prs.map(pr => pr.html_url);
67+
core.info(`prs: ${pr_urls.join(",\n")}`);
5168
52-
const prs = resp.data.map(pr => {
69+
return prs.map(pr => {
5370
return {
5471
number: pr.number,
5572
title: pr.title,

0 commit comments

Comments
 (0)