I'm using Probot/Octocat to run some code checks, one of the things I'm doing is checking against a list of breaking changes in a separate repository on an internal package update. Is there any easy way to read a file (.md) from a separate private repository easily within Probot on a pull request action, or do I need a manual request?
Asked
Active
Viewed 342 times
1 Answers
1
You can use Probot's Octokit instance to interact with GitHub API in an easy way.
Checking Octokit's API Docs, you can find here a way to get the content of a file:
context.octokit.rest.repos.getContent({
owner,
repo,
path
});
I used Octokit's API for reading a file in this script if you want to check an example

OscarDOM
- 716
- 5
- 15
-
Do you know if there's a way to get content from a specific branch? (Other than main/master) – Ben Rauzi Apr 22 '22 at 04:28
-
Yes, there is an optional parameter: `ref` where you can specify that. You can find the reference [here](https://octokit.github.io/rest.js/v18#repos-get-content) – OscarDOM Apr 22 '22 at 18:07