JJ / github-pr-contains-action

Action that checks whether the body or diff in a PR contains a certain word.
MIT License
35 stars 34 forks source link

"Error: not found" when working with a private repository #85

Closed paulbakkerbloom closed 1 year ago

paulbakkerbloom commented 1 year ago

Hi @JJ,

Unfortunately, your recent changes did not fix my error. I'm working in a private repo.

jobs:
  check_pr:
    runs-on: ubuntu-latest
    steps:
      - name: Check PR
        uses: JJ/github-pr-contains-action@releases/v8
        with:
          github-token: ${{github.token}}
          bodyDoesNotContain: ''
          bodyContains: '- [x] blabla'
          diffContains: ''
          filesChanged: 1
          linesChanged: 1

In the first screenshot I the PR body does indeed not contain the required text. It gives two errors:

image

In this screenshot it does, but still gives the second error:

image
JJ commented 1 year ago

Is it possible to see a screenshot of the PR body itself? Maybe send it to me in private if you can't share it publicly?

paulbakkerbloom commented 1 year ago
image

It's just a test, so nothing to see really :)

JJ commented 1 year ago

Hum. I wonder where's that error. I think what I'm going to do is to at least show where the workflow is so that we see where that error is produced, and what exactly is "Not found". If it's not the body, can't see how the diff can not be found...

JJ commented 1 year ago

Can you please try with @master? I've added debug to understand where it's failing.

JJ commented 1 year ago

I've added a stack trace too (which I should have probably done from the get go)

paulbakkerbloom commented 1 year ago
image
JJ commented 1 year ago

Well, that's interesting. Let me check that. Thanks!

JJ commented 1 year ago

Pushed another change to master (If you want to pair on this, I'm game for the next hour or so...)

JJ commented 1 year ago

I'm starting to think his line:

const result = await github.request(diff_url);

is not working on private repositories because you need to attach the token or something. It should be in the github object, somehow, but...

I'll stop bothering you. Looks like the key is that it's a private repository, more than anything else. I think I can take it from here.

JJ commented 1 year ago

Yay, correct: Captura de pantalla de 2023-01-23 12-15-26

Can reproduce it locally. If you don't mind, I will edit the issue to reflect more clearly what's going on

JJ commented 1 year ago

I'm researching the issue, and looks like the default github token does not have the repo scope that's required to make API requests in private repositories. There's not much I can do on my side, other than document that. Can you please check if that's the case? You would need to create a token with such scope, and upload it as GITHUB_SECRET.

JJ commented 1 year ago

I've pushed to master a solution that includes an informative error message. However, that might not be satisfactory for you if you don't want to check for files and all that, just the body. If that's the case, please tell me so; if it's not, I'll release this (not-really-a) solution

reetika-roy commented 1 year ago

I ran into the same issue in a private repository. Pointing to master worked- when will the fix be released?

JJ commented 1 year ago

Version 9 includes it already. It's not called love for private repos for no reason. Please bear in mind that it's not the same functionality. You'd need a different token for that.