File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -25,16 +25,32 @@ jobs:
2525 if (context.event_name !== 'schedule') {
2626 core.setOutput('should_run', 'true');
2727 return;
28- }
29- const since = new Date(Date.now() - 24*60*60*1000);
30- const params = { owner: context.repo.owner, repo: context.repo.repo, state: 'closed', per_page: 100 };
31- const pulls = await github.paginate(github.rest.pulls.list, params);
32- const merged = pulls.filter(p => p.merged_at && new Date(p.merged_at) >= since);
33- core.setOutput('should_run', merged.length > 0 ? 'true' : 'false');
28+ }
29+ const since = new Date(Date.now() - 24*60*60*1000).toISOString();
30+ const query = [
31+ "repo:" + context.repo.owner + "/" + context.repo.repo,
32+ "is:pr",
33+ "is:merged",
34+ `merged:>=${since}`
35+ ].join(" ")
36+
37+ const results = await github.rest.search.issuesAndPullRequests({
38+ q: query,
39+ per_page: 1
40+ })
41+
42+ const count = results.data.total_count
43+ core.info(`Found ${count} merged PR(s) in last 24 hours`)
44+
45+ const shouldRun = count > 0 ? "true" : "false"
46+ core.info(`should_run = ${shouldRun}`)
47+ core.setOutput("should_run", shouldRun)
48+
3449
3550 setup :
3651 name : Define Build Matrix
3752 runs-on : ubuntu-latest
53+ needs : pr-check
3854 if : github.event_name != 'schedule' || needs.pr-check.outputs.should_run == 'true'
3955 outputs :
4056 matrix : ${{ steps.set-matrix.outputs.matrix }}
You can’t perform that action at this time.
0 commit comments