Repository navigation
Description
Description
When committing many files (e.g. 187 files in a smoke-test deploy), the action makes one createBlob API call per file sequentially before calling createTree. This results in ~190 REST API calls for a single commit, which triggers GitHub's secondary rate limit on the GitHub App installation.
This was observed in vig-os/devcontainer-smoke-test run #28, attempt 2 where the action failed with:
You have exceeded a secondary rate limit. Please wait a few minutes before you try again.
This is distinct from the transient Not Found refs error tracked in vig-os/devcontainer#354 (which hit attempt 1 of the same run), but both affect the same step and share the same root weakness: no retry/backoff, and an unnecessarily high number of API calls.
Steps to Reproduce
- Use the action to commit ~187 files (e.g. a full workspace deploy)
- Trigger the workflow in close proximity to other workflows using the same GitHub App installation
- Observe step failure with
secondary rate limiterror
Expected Behavior
The action should minimize API calls and complete successfully even when committing a large number of files, without triggering GitHub's secondary rate limits.
Actual Behavior
The action makes 187 individual createBlob calls plus 1 createTree call, 1 createCommit call, and 1 updateRef call (~190 total). The rapid-fire blob creation triggers GitHub's secondary rate limit, causing the step to fail.
Environment
- Runner: GitHub-hosted
ubuntu-22.04 - Action version:
c0024cbad0e501764127cccab732c6cd465b4646 - Files committed: 187 (text-only: YAML, Markdown, shell scripts, Python, TOML, JSON)
Additional Context
Current implementation in src/commit.ts (createTree function):
for (const filePath of filePaths) {
const { sha, mode } = await createBlob(octokit, owner, repo, filePath);
treeEntries.push({ path: filePath, mode, type: "blob", sha });
}Each iteration is a separate POST /repos/{owner}/{repo}/git/blobs call. For 187 files, this alone accounts for ~98% of all API calls.
Possible Solution
Use inline content in the createTree API instead of pre-creating blobs. The GitHub Create a tree endpoint accepts a content field on each tree entry — GitHub creates the blob server-side, eliminating all individual createBlob calls.
This would reduce the commit flow from ~192 API calls to 5:
getRef(1 call)getCommit(1 call)createTreewith inline content (1 call)createCommit(1 call)updateRef(1 call)
Caveats:
- Binary files: The inline
contentfield is a UTF-8 string. Binary files cannot use this path and would still require individualcreateBlobcalls withencoding: "base64". The implementation should detect binary files (e.g. by attempting UTF-8 decode or checking file extension/MIME type) and fall back tocreateBlobfor those. - Large payloads: All file contents are sent in a single
createTreerequest body. For very large files or a very large number of files, this could hit GitHub's request payload size limits. A chunking strategy or a hybrid approach (inline small files, blob-create large ones) may be needed. - Complementary to retry: This optimization eliminates the secondary rate limit trigger but does not address the transient
Not Foundrefs error from vig-os/devcontainer#354. Both fixes are independent and complementary.
Activity
[-][BUG] Excessive API calls in createTree cause secondary rate limit failures[/-][+]Optimize createTree to reduce GitHub REST API usage[/+]feat: sequential binary blob creation to avoid rate-limit bursts (fix #…
feat: optimize createTree to reduce REST API usage (#19)
release: Release 0.2.0
chore(meta): fix action author and refresh README version pins (#68)