danger / danger/swift

Cannot fetch PR comments using `danger.api.github`

Open
#591 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
1.1k
Forks
152
Avg merge
9h 54m
Merged PRs (30d)
2

Description

**_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///issues//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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.