Read file from GH repository (Probot)

444 views Asked by At

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?

1

There are 1 answers

2
OscarDOM On BEST ANSWER

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