CodeRoadMap
首页路线题库资源库文章社区
CodeRoadMap

程序员的学习成长路线图。内容免费开放,登录后可同步路线图与课时进度。

由 程序员柏风 独立维护 · 关于作者

学习

  • 路线图
  • 课程
  • 面试题
  • 文章
  • 我

更多

  • 资源
  • 社区
  • 关于作者
  • 内容说明

© 2026 CodeRoadMap

津ICP备2026012044号-1·津公网安备12011002026155号·coderoadmap@126.com
PowerShell 入门/课时/GitHub Actions Windows
RawBlame
课时目录12 节

PowerShell 入门

  1. 01PowerShell 是什么
  2. 02Cmdlet 基础
  3. 03管道与对象
  4. 04变量与类型
  5. 05脚本与函数
  6. 06文件与路径
  7. 07远程与会话
  8. 08PowerShell vs Bash
  9. 09Windows 部署 CodeRoadMap
  10. 10GitHub Actions Windows
  11. 11Windows 容器简介
  12. 12综合练习

GitHub Actions Windows

windows-latest runner、与 ci.yml 关系。

25 分钟

GitHub Actions Windows

GitHub Actions 提供 windows-latest runner,预装 PowerShell 5.1 与 pwsh。本站 .github/workflows/ci.yml 主 CI 跑在 ubuntu-latest;Windows job 适合测 PowerShell 脚本、.NET 或跨平台兼容性。

学习目标

  • 在 workflow 里使用 runs-on: windows-latest
  • 写 PowerShell 步骤与 Bash 步骤的差异
  • 理解 ci.yml 与 Windows 专项 job 的关系

核心内容

ci.yml 现状

仓库根目录 .github/workflows/ci.yml:

jobs:
  backend:
    runs-on: ubuntu-latest
    # mvn verify

  platform:
    runs-on: ubuntu-latest
    # npm ci / lint / test / build

Java 与 Node 构建均在 Linux runner 完成(gha-java、gha-node)。

添加 Windows job 示例

  ps-scripts:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - name: List deploy scripts
        shell: pwsh
        run: Get-ChildItem deploy/scripts/*.ps1 | Select-Object Name

shell: pwsh 用 PowerShell 7;省略时 Windows 默认 powershell(5.1)。步骤内用 $env:VAR 读 secrets,勿 echo 敏感值。

步骤 shell 对照

shell 值环境
bashLinux/macOS 默认
pwshPowerShell 7(跨平台)
powershellWindows 5.1
cmdWindows CMD

路径用反斜杠或正斜杠均可(gha-steps)。

何时需要 Windows runner

  • 验证 sync-courses.ps1、package-prod.bat 在干净 Windows 环境可执行
  • 构建依赖 Windows SDK 的项目
  • 多数 CodeRoadMap CI 不必 Windows——Linux 已覆盖 backend + platform

练习

  • 打开 ci.yml,确认两个 job 的 runs-on
  • 写一段 workflow 片段: + +
windows-latest
pwsh
Get-ChildItem deploy\scripts
  • 对比同一步在 ubuntu bash 与 windows pwsh 的路径写法
  • 小结

    windows-latest + shell: pwsh 跑 PowerShell 脚本;本站主 CI 仍在 ubuntu-latest。 下一课 Windows 容器简介。

    加载本节练习…
    ← 上一课Windows 部署 CodeRoadMap下一课 →Windows 容器简介