'Probot Octokit - Get file from specific branch

I'm using Probot's Octokit to read a file from a repo:

const content = await context.octokit.repos.getContent({owner: "OWNER", repo: "REPO", path:"PATH"})

However this only works for the master branch, is there a way to get the file from another branch (e.g. the branch that the pull request action is coming from)? This isn't directly stated in the docs itself.

Thanks



Solution 1:[1]

Yes, it is possible.

When using Octokit, there is an optional parameter: ref where you can specify the branch or commit hash. You can find the reference here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OscarDOM