Updating a file's content without down/upload (i.e. append)?

I’ve was making use of Octokit to read a file (>10MB) from from my repo, add a line and then commit the updated file.

This consisted of octokit.request('https://api.github.com/repos/{owner}/{repo}/git/trees/main') and octokit.request('GET /repos/{owner}/{repo}/git/blobs/{file_sha}' to get the SHA and retrieve the existing commit. I was then writing the file to a /tmp file in an AWS Lambda function and adding the new line. Lastly, I used octokit.request('PUT /repos/{owner}/{repo}/contents/{path}' to commit the new content from the temp file.

But, obviously, this involves a large data transfer and… I’d rather not! Is there a way to achieve this without the data transfer, such as a git-apply, that I can make use of in my Lambda function? Each commit will just be an additional line, guaranteed. Not bound to Octokit, hence asking here, but this will be performed in a Lambda (ideally Node, it’s what I’m comfy with!)

Pointers appreciated. TIA!

I’ve settled on making use of the Data API, following the example here. Although this doesn’t solve the append aspect of my challenge, it does make my commits a bit more resilient against the content API’s 10 second timeout.

Big thanks to Steve @ GH for the pointers!