bazel-contrib / setup-bazel

GitHub Action to configure Bazel
MIT License
16 stars 5 forks source link

Set octokit's baseUrl explicitly to make it work with self-hosted GitHub Enterprise Servers #24

Closed markszabo closed 1 month ago

markszabo commented 1 month ago

At my company we use a self-hosted GitHub Enterprise Server and to use GitHub Actions from github.com we are syncing them to a local organization. I tried to do this with https://github.com/bazel-contrib/setup-bazel however it fails to download bazelisk with this error:

Run synced-actions/bazel-contrib-setup-bazel@0.8.4
Configure Bazel
Setup Bazelisk
  Error: HttpError: Not Found
      at /runner/_work/_actions/synced-actions/bazel-contrib-setup-bazel/0.8.4/dist/node_modules/@octokit/request/dist-node/index.js:124:1
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at downloadBazelisk (/runner/_work/_actions/synced-actions/bazel-contrib-setup-bazel/0.8.4/dist/index.js:74:1)
      at setupBazelisk (/runner/_work/_actions/synced-actions/bazel-contrib-setup-bazel/0.8.4/dist/index.js:43:1)
      at setupBazel (/runner/_work/_actions/synced-actions/bazel-contrib-setup-bazel/0.8.4/dist/index.js:26:1)
      at run (/runner/_work/_actions/synced-actions/bazel-contrib-setup-bazel/0.8.4/dist/index.js:12:1)

The issue seems to be that octokit.rest.repos.listReleases defaults to using the GitHub API of the instance it's running on (in my case our GitHub Enterprise Server's API), so it is checking the releases of the bazelbuild/bazelisk repository on our internal GitHub Enterprise Server, where that repository doesn't exist.

This PR adds a baseUrl pointing to github.com's API endpoint. This is the default behavior when running on github.com, so this only changes the behavior when running in an environment where the API endpoint is different (I believe this is only GitHub Enterprise Servers). The change results in always looking for the bazelbuild/bazelisk repository on github.com, which is the behavior most users would expect in my opinion.

p0deje commented 1 month ago

Thank you!