Support of GitHub Enterprise
Opened this issue · 4 comments
I found this action and it looked pretty cool, so I tried to run it on a GitHub Enterprise instance, but it failed because it tried to send the report to api.github.com/...
instead of the URL which should be in GITHUB_API_URL
- according to https://docs.github.com/en/actions/reference/environment-variables
Run vebr/jest-lcov-reporter@v0.2.0
RequestError [HttpError]: Bad credentials
at /home/runner/_work/_actions/vebr/jest-lcov-reporter/v0.2.0/dist/main.js:6018:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async main$1 (/home/runner/_work/_actions/vebr/jest-lcov-reporter/v0.2.0/dist/main.js:22950:2) {
name: 'HttpError',
status: 401,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
connection: 'close',
'content-length': '80',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Tue, 02 Feb 2021 10:55:51 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
status: '401 Unauthorized',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': 'DB6E:35E5:47937F:C53B69:60192FB7',
'x-ratelimit-limit': '60',
'x-ratelimit-remaining': '59',
'x-ratelimit-reset': '1612266951',
'x-ratelimit-used': '1',
'x-xss-protection': '1; mode=block'
},
request: {
method: 'POST',
url: 'api.github.com/repos/telltale/frontend/issues/589/comments',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'octokit.js/16.35.0 Node.js/12.13.1 (Linux 4.19; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: `{"body":"Coverage after merging <b>speed-up-jest-tests</b> into <b>develop</b><table> [TABLE CoNTENT OMMITED for opening THIS GITHUB ISSUE]</table></details>"}`,
request: { hook: [Function: bound bound register], validate: [Object] }
},
documentation_url: 'docs.github.com/rest'
}
Error: Bad credentials
Hello @vebr, thank you for the response.
The relevant part of my workflow file is the following:
---
name: Build
on:
pull_request:
jobs:
Test:
runs-on: [ self-hosted ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- run: yarn install
- run: yarn test --coverage --runInBand --json --outputFile=result.json --testLocationInResults
- uses: vebr/jest-lcov-reporter@v0.2.0
if: always()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info
- uses: tanmen/jest-reporter@v1
if: always()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Though now that you mention that it works for you, I guess the difference is probably hidden behind runs-on: [ self-hosted ]
, so it's probably not enough to reproduce and I have to dig deeper into our self-hosted
runner setup.
After digging deeper I'm really confused about what is going on here.
I found that the github action package you use is trying to read process.env['GITHUB_API_URL']
in
https://github.com/actions/toolkit/blob/af821474235d3c5e1f49cee7c6cf636abb0874c4/packages/github/src/internal/utils.ts#L23-L25 and I checked that the env variable is set to our GHE API URL as expected (with - run: echo $GITHUB_API_URL
in the workflow file before running the tests).
Still, the request is using url: 'api.github.com/...
as you can see in the error above 🙁
@slaweet Do you use forks in your company? I have this same problem on a library I'm working on where we use forks of the main repo and create pull requests from the forks to that repo. The problem for me at least is that GITHUB_TOKEN
only allows READ access to pull requests from forks. Reference here I tried pushing a branch with the action to the main repo and it worked without a problem. So If you are using forks in your company it's likely you have the same problem