Skip to content

Commit

Permalink
Try use github.token for Octokit
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Feb 7, 2024
1 parent 4787a09 commit 913e128
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
enable-plugins: true
env:
ACTIONS_STEP_DEBUG: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Show Nu Path and Related Assets
run: which $(printf nu | tr '[:upper:]' '[:lower:]') && echo "Dir contents --->:" && ls -la "$(dirname `which nu`)"
shell: bash
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/use-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
enable-plugins: true
env:
ACTIONS_STEP_DEBUG: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Show Nu Path and Related Assets
run: which $(printf nu | tr '[:upper:]' '[:lower:]') && echo "Dir contents --->:" && ls -la "$(dirname `which nu`)"
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.

### Features

- Add default github-token input support
- Add default github-token input support, and `GITHUB_TOKEN` is no longer required anymore to avoid **API rate limit exceeded** error

### Miscellaneous Tasks

Expand Down
24 changes: 6 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Then you can set the command you want to run in the following steps, and don't f
to make the commands be executed by `nu`:

```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
version: "0.80" # Don't use 0.80 here, as it was a float number and will be convert to 0.8, you can use v0.80/0.80.0 or '0.80'
- run: print $'Nu version info:(char nl)'; version
Expand Down Expand Up @@ -77,7 +77,7 @@ To use modules in `Nu`, please refer to the following examples:

```yaml
- name: Setup nu
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -94,7 +94,7 @@ You have to wrap the `nu` code in `nu -c ""`, and the nu version should be equal

```yaml
- name: Setup nu
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -113,7 +113,7 @@ Again, the nu version should be equal to or above `0.69`.

```yaml
- name: Setup nu@latest
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -140,7 +140,7 @@ They are not perfect yet, but they do work. BTW: Please tell me if you found a b
`Nushell` is currently in active development, if you want to use the latest features it's also available by set the version to `nightly`, just as below:

```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
version: nightly # Will download and setup the latest nightly version of Nushell
- run: print $'Nu version info:(char nl)'; version
Expand Down Expand Up @@ -172,26 +172,14 @@ If you want to use the latest version of nushell you can specify this by set `ch
the latest version:
```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
check-latest: true
- run: print $'Nu version info:(char nl)'; version
```
**Note**: **Before Nushell reaches 1.0, each version may change a lot, it is recommend that you use a specified version instead**.
In rare circumstances you might get rate limiting errors, this is caused by the
workflow has to make requests to GitHub API in order to list available releases.
If this happens you can set the `GITHUB_TOKEN` environment variable.

```yaml
- uses: hustcer/setup-nu@v3.8
with:
version: "0.80"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

### Inputs
| Name | Required | Description | Type | Default |
Expand Down
22 changes: 6 additions & 16 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
在大多数情况下,你只需要在工作流程中通过 `version` 字段指定要使用的 Nushell 的版本即可。比如下面的例子将会安装 [Nushell](https://github.com/nushell/nushell)`v0.80`版本。然后你可以在后续步骤中配置你想运行的命令,最后别忘了设置`shell: nu {0}`以使命令被`nu`执行:

```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
version: "0.80" # 不要使用 0.80, 它会被认为是一个浮点数并转换为 0.8, 你可以使用 v0.80/0.80.0 或者 '0.80'(加了引号变成字符串)
- run: print $'Nu version info:(char nl)'; version
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

```yaml
- name: Setup nu
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -89,7 +89,7 @@ jobs:

```yaml
- name: Setup nu
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -108,7 +108,7 @@ jobs:

```yaml
- name: Setup nu@latest
uses: hustcer/setup-nu@v3.8
uses: hustcer/setup-nu@v3.9
with:
version: 0.90.1
env:
Expand All @@ -135,7 +135,7 @@ jobs:
`Nushell` 目前正处于活跃开发期,如果你想使用最新的特性也可以通过将版本设置为 `nightly` 获得,比如下面的例子:

```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
version: nightly # Will download and setup the latest nightly version of Nushell
- run: print $'Nu version info:(char nl)'; version
Expand Down Expand Up @@ -165,24 +165,14 @@ jobs:
如果你想使用最新版本的 Nushell,你可以通过设置 `check-latest` 为 `true` 来做到(它与`version: '*'`配置的效果相同,但更易读)。例如,以下将会安装最新版本的 Nushell:
```yaml
- uses: hustcer/setup-nu@v3.8
- uses: hustcer/setup-nu@v3.9
with:
check-latest: true
- run: print $'Nu version info:(char nl)'; version
```
**备注**: **_在 Nushell 1.0 发布之前,每个版本可能会有较大的变化,所以建议您使用指定的 Nushell 版本_**。
在极少数情况下,你可能会看到速率限制之类的错误,这是因为这个工作流程必须向 GitHub API 发出请求,以便查询可用的 Nushell 版本。如果发生这种情况,你可以通过设置 `GITHUB_TOKEN` 环境变量来避免该问题:

```yaml
- uses: hustcer/setup-nu@v3.8
with:
version: "0.80"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

### 输入
| 名称 | 必填 | 描述 | 类型 | 默认值 |
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ async function main() {
core.setFailed(`Invalid version: ${versionSpec}`);
}

core.exportVariable('GITHUB_TOKEN', githubToken);
const tool = await setup.checkOrInstallTool({
checkLatest,
githubToken,
enablePlugins,
bin: 'nu',
owner: 'nushell',
Expand Down
4 changes: 3 additions & 1 deletion src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface Tool {
owner: string;
/** The GitHub repo name. */
name: string;
/** The GitHub token to use for API requests. */
githubToken: string;
/** Set this option to `true` if you want to check for the latest version. */
checkLatest: boolean;
/** Set this option to `true` if you want to register plugins. */
Expand Down Expand Up @@ -174,7 +176,7 @@ function filterLatestNightly(response: any, features: 'default' | 'full'): Relea
async function getRelease(tool: Tool): Promise<Release> {
const { owner, name, versionSpec, checkLatest = false, features = 'default' } = tool;
const isNightly = versionSpec === 'nightly';
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
const octokit = new Octokit({ auth: tool.githubToken });

return octokit
.paginate(octokit.repos.listReleases, { owner, repo: name }, (response, done) => {
Expand Down

0 comments on commit 913e128

Please # to comment.