Skip to content

Commit 2ddcae6

Browse files
authored
Merge pull request #72 from MisaelMa/publish/trigger-all
feat(core): test
2 parents 0920822 + 0de2eb6 commit 2ddcae6

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

common/scripts/github-actions.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,29 @@ async function getCommitsPR(url) {
193193

194194
}
195195
module.exports = async ({ github, context, core }) => {
196-
const branch = context.ref.split('/').slice(2).join('/')
196+
// For pull_request events, use the target branch (base_ref), not the PR ref
197+
const branch = context.payload.pull_request
198+
? context.payload.pull_request.base.ref
199+
: context.ref.split('/').slice(2).join('/');
200+
201+
console.log("branch:", branch);
202+
console.log("eventName:", context.eventName);
197203

198204
const branchs = ['next','beta', 'alpha','dev']
199205
const eventName = context.eventName
200206
let commits = context.payload.commits || [];
201207

202208
if(eventName==='pull_request'){
203-
const commits_url = context.payload.pull_request.commits_url
204-
const commits_local = await getCommitsPR(commits_url)
209+
const { owner, repo } = context.repo;
210+
const pull_number = context.payload.pull_request.number;
211+
console.log(`Fetching commits for PR #${pull_number}...`);
212+
const { data: commits_local } = await github.rest.pulls.listCommits({
213+
owner,
214+
repo,
215+
pull_number,
216+
per_page: 100,
217+
});
218+
console.log(`Found ${commits_local.length} commits in PR`);
205219
commits = commits_local.map(({commit})=>commit)
206220
}
207221
const scopes = getScopes(commits);

0 commit comments

Comments
 (0)