Skip to content

Commit d24e383

Browse files
authored
feat: pass github token for mise calls (#205)
1 parent bb86fea commit d24e383

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
shellcheck = "0.9.0"
3232
working_directory: app # [default: .] directory to run mise in
3333
reshim: false # [default: false] run `mise reshim --all`
34+
github_token: ${{ secrets.GITHUB_TOKEN }} # [default: ${{ github.token }}] GitHub token for API authentication
3435
- run: shellcheck scripts/*.sh
3536
test:
3637
runs-on: ubuntu-latest
@@ -41,6 +42,21 @@ jobs:
4142
- run: node ./my_app.js
4243
```
4344
45+
## GitHub API Rate Limits
46+
47+
When installing tools hosted on GitHub (like `gh`, `node`, `bun`, etc.), mise needs to make API calls to GitHub's releases API. Without authentication, these calls are subject to GitHub's rate limit of 60 requests per hour, which can cause installation failures.
48+
49+
```yaml
50+
- uses: jdx/mise-action@v2
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
# your other configuration
54+
```
55+
56+
**Note:** The action automatically uses `${{ github.token }}` as the default, so in most cases you don't need to explicitly provide it. However, if you encounter rate limit errors, make sure the token is being passed correctly.
57+
58+
## Alternative Installation
59+
4460
Alternatively, mise is easy to use in GitHub Actions even without this:
4561

4662
```yaml

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ inputs:
5757
required: false
5858
default: "false"
5959
description: if true, will run `mise reshim --all` after setting up mise
60+
github_token:
61+
required: false
62+
description: |
63+
GitHub token for API authentication to avoid rate limits when installing GitHub-hosted tools.
64+
Defaults to the automatic GitHub token.
65+
default: ${{ github.token }}
6066
outputs:
6167
cache-hit:
6268
description: A boolean value to indicate if a cache was hit.

dist/index.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ async function setEnvVars(): Promise<void> {
5353
const logLevel = core.getInput('log_level')
5454
if (logLevel) set('MISE_LOG_LEVEL', logLevel)
5555

56+
const githubToken = core.getInput('github_token')
57+
if (githubToken) {
58+
set('GITHUB_TOKEN', githubToken)
59+
} else {
60+
core.warning(
61+
'No GITHUB_TOKEN provided. You may hit GitHub API rate limits when installing tools from GitHub.'
62+
)
63+
}
64+
5665
set('MISE_TRUSTED_CONFIG_PATHS', process.cwd())
5766
set('MISE_YES', '1')
5867

0 commit comments

Comments
 (0)