Skip to content

Commit

Permalink
ci: make git-diff-develop work for PRs from foreign repos
Browse files Browse the repository at this point in the history
The gh API requires authentication, even if the API endpoints do not. We
can just fetch the PR URL directly without shelling out.
  • Loading branch information
legobeat committed Sep 19, 2024
1 parent f06b7a0 commit 3e6d1ba
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .circleci/scripts/git-diff-develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ async function getBaseRef(): Promise<string | null> {
return null;
}

// We're referencing the CIRCLE_PULL_REQUEST environment variable within the script rather than
// passing it in because this makes it easier to use Bash parameter expansion to extract the
// PR number from the URL.
const result = await exec(`gh pr view --json baseRefName "\${CIRCLE_PULL_REQUEST##*/}" --jq '.baseRefName'`);
const baseRef = result.stdout.trim();
const pull = await (await fetch(process.env.CIRCLE_PULL_REQUEST)).json();
const baseRef = pull.base.ref;
return baseRef;
}

Expand Down

0 comments on commit 3e6d1ba

Please sign in to comment.