diff --git a/.buildkite/ci.mjs b/.buildkite/ci.mjs index c9c0051987..62ef231ba1 100644 --- a/.buildkite/ci.mjs +++ b/.buildkite/ci.mjs @@ -14,6 +14,7 @@ import { getCommitMessage, getLastSuccessfulBuild, getMainBranch, + getRepositoryOwner, getTargetBranch, isBuildkite, isFork, @@ -370,7 +371,7 @@ async function main() { } console.log("Checking changed files..."); - const baseRef = getCommit(); + const baseRef = isFork() ? `${getRepositoryOwner()}:${getCommit()}` : getCommit(); console.log(" - Base Ref:", baseRef); const headRef = lastBuild?.commit_id || getTargetBranch() || getMainBranch(); console.log(" - Head Ref:", headRef); diff --git a/scripts/utils.mjs b/scripts/utils.mjs index 185bebf7d7..11bc2fbf96 100644 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -376,6 +376,20 @@ export function getRepository(cwd) { } } +/** + * @param {string} [cwd] + * @returns {string | undefined} + */ +export function getRepositoryOwner(cwd) { + const repository = getRepository(cwd); + if (repository) { + const [owner] = repository.split("/"); + if (owner) { + return owner; + } + } +} + /** * @param {string} [cwd] * @returns {string | undefined}