> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 GitHub Actions 中安装和运行 Bun

使用官方的 [`setup-bun`](https://github.com/oven-sh/setup-bun) GitHub Action 在你的 GitHub Actions 运行环境中安装 `bun`。

```yaml workflow.yml icon="file-code" theme={null}
name: my-workflow
jobs:
  my-job:
    name: my-job
    runs-on: ubuntu-latest
    steps:
      # ...
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2 # [!code ++]

      # 运行任何 `bun` 或 `bunx` 命令
      - run: bun install # [!code ++]
      - run: bun index.ts # [!code ++]
      - run: bun run build # [!code ++]
```

***

要指定要安装的 Bun 版本：

```yaml workflow.yml icon="file-code" theme={null}
name: my-workflow
jobs:
  my-job:
    name: my-job
    runs-on: ubuntu-latest
    steps:
      # ...
      - uses: oven-sh/setup-bun@v2
        with: # [!code ++]
          bun-version: 1.3.3 # 或 "latest", "canary", <sha> # [!code ++]
```

***

参见 [`setup-bun` 自述文件](https://github.com/oven-sh/setup-bun) 了解所有选项。
