fix(ci): limit api rate usage

This commit is contained in:
Kevin Duret 2024-12-05 17:42:39 +01:00
parent 3227104fdb
commit adf172ccce
1 changed files with 10 additions and 12 deletions

View File

@ -114,24 +114,22 @@ runs:
const warningNoPromote = 'No packages are promoted because push is not related to a hotfix/release pull request.'; const warningNoPromote = 'No packages are promoted because push is not related to a hotfix/release pull request.';
const commitSha = context.sha; const commitSha = context.sha;
const { data: { items } } = await github.rest.search.issuesAndPullRequests({ const pulls = await github.rest.pulls.list({
q: `${commitSha} type:pr is:merged` owner: context.repo.owner,
repo: context.repo.repo,
sort: 'updated',
direction: 'desc',
state: 'closed',
per_page: 100
}); });
if (items.length === 0) { const pr = pulls.data.find(p => p.merge_commit_sha === commitSha);
if (!pr) {
core.warning(warningNoPromote); core.warning(warningNoPromote);
return; return;
} }
const prNumber = items[0].number; const prBaseRef = pr?.base?.ref || 'unknown';
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
const prBaseRef = pr.data?.base?.ref || 'unknown';
let releaseType = ''; let releaseType = '';
switch (true) { switch (true) {
case /^release.+/.test(prBaseRef): case /^release.+/.test(prBaseRef):