要将 Windows 10 部署为 GitHub Actions 的 CI 机器,需要完成以下步骤:
在 GitHub 上创建一个仓库,并配置好需要运行 CI 的代码。
在仓库的 Settings 页面中,选择 Secrets 选项卡,添加凭据(如登录信息、API 密钥等),以便在 CI 中使用。
在 Windows 10 上安装 Git 和 Docker Desktop。
将代码克隆到您的 Windows 10 机器上:
git clone https://github.com/<username>/<reponame>.git
- 创建一个名为
.github/workflows的目录,并在其中创建一个 YAML 文件,例如ci.yml。在其中定义 CI 作业的步骤和条件,例如:
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: pytest
将更改推送到 GitHub 仓库。GitHub 将自动检测新的
.github/workflows目录和ci.yml文件,并开始运行 CI 作业。您可以在 GitHub 仓库的 Actions 页面中查看作业的状态和日志。
参考文档:




