HTTP 403 when calling createOrUpdatePR
- Dominant language
- TypeScript
- Stars
- 5.5k
- Forks
- 381
- Avg merge
- 2h 8m
- Merged PRs (30d)
- 6
Description
First issue - apologies for any mistakes! 😃
First off, thanks for creating such an awesome tool! This is a really cool idea and I'm glad you shared it with the world!
I am working in a Dangerfile that runs on a self-hosted Peril server. My repo is at https://github.com/markpar/peril-settings and the Dangerfile I'm writing is https://github.com/markpar/peril-settings/blob/master/org/prForSubtreeChanges.ts. My GitHub app is named `peril-markpar`, and my Heroku app is https://mp-peril-test.herokuapp.com.
My use case is a developer opening a PR with changes in a specific folder. When this happens, I want to create a separate PR to move those changes to another repo. The 'specific folder' here is a subtree, and the intent is to ensure that any library changes made in the super repo make it back to the sub repo.
I found the function `createOrUpdatePR` and that looks like it will do what I'm looking for with one single call. Here's how I'm calling it:
```
let response = await danger.github.utils.createOrUpdatePR(
{
owner: org,
repo: destRepo,
title: `Merge changes from ${pr.repo}/pulls/${pr.number}`,
body: `Files in ${pr.repo}/${subtreePath} were changed, this auto-generated PR moves those changes over.`,
baseBranch: destRepoBranch,
newBranchName: mergeBranch,
commitMessage: `Migrate changes in ${pr.repo}/${subtreePath}`,
},
newFileMap
);
```
When I run this code, the merge branch (`newBranchName`) is created (yay!), but the PR is not created. This error is thrown:
```
{
"code": 403,
"message": "{\"message\":\"Resource not accessible by integration\",\"documentation_url\":\"https://developer.github.com/v3/pulls/#create-a-pull-request\"}"
}
```
However, if I call the GitHub API directly,
```
let response = await danger.github.api.pullRequests.create(
{
owner: org,
repo: destRepo,
title: `Merge changes from ${pr.repo}/pulls/${pr.number}`,
body: `Files in ${pr.repo}/${subtreePath} were changed, this auto-generated PR moves those changes over.`,
base: destRepoBranch,
head: mergeBranch,
commitMessage: `Migrate changes in ${pr.repo}/${subtreePath}`
});
```
it succeeds and the PR is created.
I've checked permissions settings for my Peril GitHub application, and I think everything that can be read-write is set that way. :) Is there anything else I could try?
Happy to help out however I can! If you have any debugging suggestions, I can definitely try them out!
Contributor guide
Assessment
This issue has not been assessed yet.