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

# GitHub Actions - GitHub Copilot SDK for Laravel

> 說明如何在 GitHub Actions 中使用 Laravel Copilot SDK，包含 Copilot CLI 安裝與 token 認證設定。

## 在 GitHub Actions 中使用

以下範例是在 GitHub Actions 中執行 Artisan 指令，並在其中使用 Copilot CLI。

在 GitHub Actions 中一般以 stdio 模式使用。

## 直接安裝 `copilot` 指令

```yaml theme={null}
      - name: Install Copilot CLI
        run: |
          curl -fsSL https://gh.io/copilot-install | bash
          copilot version

      - name: Run command
        run: php artisan copilot:ping
        env:
          COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
```

* 透過 `copilot-install` 進行安裝。path 維持 `copilot` 即可，無需額外設定。
* 以 `COPILOT_GITHUB_TOKEN` 進行認證。只要是 Copilot CLI 支援的認證方式（如 `GH_TOKEN` 或 `GITHUB_TOKEN`）皆可。
* Token 需要具備 `Copilot Requests` 權限，因此預設的 `GITHUB_TOKEN` 通常無法使用。

## 使用 `gh` 指令

GitHub CLI 2.86.0 加入了 Copilot 安裝功能。在一般的 GitHub Actions 環境中預裝了 `gh` 指令，因此無需額外安裝即可使用。首次執行 `gh copilot ...` 指令時應該會自動安裝 Copilot，故僅執行 `gh copilot version` 即可。

> gh version 2.86.0 (2026-01-21)
> [https://github.com/cli/cli/releases/tag/v2.86.0](https://github.com/cli/cli/releases/tag/v2.86.0)
> ✓ Copilot CLI installed successfully

```yaml theme={null}
      - name: Install Copilot CLI
        run: |
          gh --version
          gh copilot version

      - name: Run command
        run: php artisan copilot:ping
        env:
          COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
          COPILOT_CLI_PATH: "gh copilot"
```

`COPILOT_CLI_PATH` 僅在為 `gh copilot` 時有特別處理，因此 `gh copilot` 以外的設定將無法運作。

<Info>
  最新資訊請參考 [GitHub 儲存庫](https://github.com/invokable/laravel-copilot-sdk)。
</Info>


## Related topics

- [GitHub Token](/zh-TW/packages/laravel-copilot-sdk/github-token.md)
- [GitHub Copilot SDK for Laravel](/zh-TW/packages/laravel-copilot-sdk/index.md)
- [認證 - GitHub Copilot SDK for Laravel](/zh-TW/packages/laravel-copilot-sdk/auth.md)
- [測試 - GitHub Copilot SDK for Laravel](/zh-TW/packages/laravel-copilot-sdk/fake.md)
- [Laravel Cloud - GitHub Copilot SDK for Laravel](/zh-TW/packages/laravel-copilot-sdk/laravel-cloud.md)
