Skip to content

fix: Support private repositories#68

Merged
Mrtenz merged 2 commits into
mainfrom
mrtenz/use-gh-api-for-file-downloads
Jun 8, 2026
Merged

fix: Support private repositories#68
Mrtenz merged 2 commits into
mainfrom
mrtenz/use-gh-api-for-file-downloads

Conversation

@Mrtenz

@Mrtenz Mrtenz commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace curl with gh api when downloading .nvmrc and yarn.lock from GitHub, so that downloads work for private repositories as well.
  • Add GH_TOKEN: ${{ github.token }} to the relevant steps to authenticate the gh CLI.

Note

Low Risk
Scoped to how two files are downloaded during CI setup; uses the standard workflow token and does not change install or caching logic.

Overview
Fixes composite action setup when the repo is private by fetching .nvmrc and yarn.lock through the GitHub Contents API with gh api instead of unauthenticated raw.githubusercontent.com URLs.

Both the compute-node-version and download-yarn-lock steps now set GH_TOKEN: ${{ github.token }} so gh can read repo contents at the requested ref. Failure/warning messages were updated to reference owner/repo@ref instead of the old raw URL.

Reviewed by Cursor Bugbot for commit c3d0059. Bugbot is set up for automated code reviews on this repo. Configure here.

@Mrtenz Mrtenz changed the title feat: Use gh api instead of curl for downloading files from GitHub fix: Support downloading files from private repositories Jun 8, 2026
@Mrtenz Mrtenz changed the title fix: Support downloading files from private repositories fix: Support private repositories Jun 8, 2026
@Mrtenz Mrtenz marked this pull request as ready for review June 8, 2026 18:49
@Mrtenz Mrtenz requested a review from a team as a code owner June 8, 2026 18:49
@Gudahtt Gudahtt requested a review from HowardBraham June 8, 2026 18:55
@HowardBraham

Copy link
Copy Markdown
Contributor

@Mrtenz have you benchmarked how this affects speed?

@Mrtenz

Mrtenz commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@Mrtenz have you benchmarked how this affects speed?

@HowardBraham I did a couple runs in a private repo with this branch and in a public repo with v3 and did not see any noticeable difference.

@HowardBraham

Copy link
Copy Markdown
Contributor

@Mrtenz can you run some tests in metamask-extension please and show me? That repo is a beast and really needs all the optimizations we can do.

@Mrtenz

Mrtenz commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@Mrtenz can you run some tests in metamask-extension please and show me? That repo is a beast and really needs all the optimizations we can do.

@HowardBraham The couple runs I did here seem to be within margin of error (some quicker, some slower) compared to other PRs: https://github.com/MetaMask/metamask-extension/actions/runs/27162320788/job/80183586844?pr=43342

@HowardBraham HowardBraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timings and functionality look good

@Mrtenz Mrtenz merged commit 63a4593 into main Jun 8, 2026
35 checks passed
@Mrtenz Mrtenz deleted the mrtenz/use-gh-api-for-file-downloads branch June 8, 2026 20:57
Mrtenz added a commit that referenced this pull request Jun 10, 2026
## Explanation

PR #68 switched all `.nvmrc` and `yarn.lock` downloads to use `gh api`
so the action would work for private repositories. However, `gh api`
counts against the GitHub REST API rate limit, which is much lower than
the unauthenticated CDN that serves `raw.githubusercontent.com`. Heavy
users of this action started hitting the rate limit.

This change reintroduces the raw URL path for public repositories.
Private and internal repositories continue to use `gh api` to
authenticate. The branch is selected based on
`github.event.repository.visibility`, which returns `public`, `private`,
or `internal` — anything other than `public` falls back to `gh api`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/bugbot) is generating a
summary for commit 8229314. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants