Probot Octokit - Get file from specific branch

1.4k views Asked by At

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

1

There are 1 answers

0
OscarDOM On

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.