在 GitHub Actions 中的使用方式
以下示例展示如何在 GitHub Actions 中运行 Artisan 命令并在其中使用 Copilot CLI。 在 GitHub Actions 中,一般以 stdio 模式使用。直接安装 copilot 命令的情况
- 使用
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 ✓ Copilot CLI installed successfully
COPILOT_CLI_PATH 只对 gh copilot 做了特殊处理,因此除 gh copilot 以外的设置无法工作。
最新信息请参考 GitHub 仓库。