Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot fetch PR comments using danger.api.github #591

Open
ipodishima opened this issue Aug 25, 2023 · 0 comments
Open

Cannot fetch PR comments using danger.api.github #591

ipodishima opened this issue Aug 25, 2023 · 0 comments

Comments

@ipodishima
Copy link

using 3.17.1 version

Hi

I need the comments from the PR to detect some stuff required for my rules processing.

I think the way to do it should be to update GithubDSL to include the required structs.

What I'm doing

ActionFlow

name: Run Unit Tests

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  checkout_and_prepare:
    [...]
  test:
    [...]
  run-danger:
    name: "Run Danger"
    needs: test
    runs-on: self-hosted
    steps:
      - name: Generate Github Token
        id: generate_token
        uses: tibdex/github-app-token@v1
        with:
          app_id: ${{ secrets.TOKEN_APP_ID }}
          private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }}
      - name: Danger
        run: |
          sh FirstPartyFrameworks/My-CI/BuildTools/danger_lint.sh
        env:
          GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
          DANGER_GITHUB_API_TOKEN: ${{ steps.generate_token.outputs.token }}

Note
If I had this step before danger

- name: Test API Call
  run: |
    curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \
         https://api.github.com/repos/<OrgName>/<RepoName>/issues/<PRNumber>/comments

The curl succeeds.

Now, in my code, if I'm doing

danger.github.api.issueComments(owner: owner,
                                        repository: repo,
                                        number: danger.github.pullRequest.number)

Then I get

Error fetching comments: Error Domain=com.nerdishbynature.octokit Code=404

After digging, I honestly think that's an issue with Authorization. But I don't know how to setup it properly or if the library needs an update.
As I said, it might also be only a matter of mapping some properties in the Github struct.

Also, as a FYI, I have those warnings at then end:

Request failed [403]: https://api.github.com/user
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/users/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/user
Response: {
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/users/users#get-the-authenticated-user"
}
Feedback: https://github.com/BeatPitch/BeatPitch-iOS/pull/443#issuecomment-1693072516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant