为何GitHub Workflows无法识别dita.bat命令?
问题原因与解决办法
核心问题
GitHub Actions默认使用Linux环境(ubuntu-latest),而dita.bat是Windows专属的批处理脚本,Linux系统无法识别执行这类文件,这就是明明文件存在却报"command not found"的根本原因。
两种解决方式
方式一:切换到Windows运行环境
把Workflow的运行环境改成Windows,同时去掉Linux专属的sudo命令(Windows中无此命令):
- name: Build WebHelp Responsive runs-on: windows-latest # 修改运行环境为Windows run: | cd oxygen-publishing-engine-3.x/bin ls ./dita.bat --input=../../doc/project-documentation/search-service-doc.ditamap --format=webhelp-responsive -Dwebhelp.publishing.template=../../templates/webhelp-documentation-template --output=../../doc/project-documentation/out
方式二:使用Linux对应脚本
同目录下的dita文件是适配Linux的shell脚本,直接运行它即可,无需sudo(GitHub Actions默认用户已有足够权限):
- name: Build WebHelp Responsive run: | cd oxygen-publishing-engine-3.x/bin ls # 若脚本无执行权限,先添加权限(仓库已配置可跳过) chmod +x dita ./dita --input=../../doc/project-documentation/search-service-doc.ditamap --format=webhelp-responsive -Dwebhelp.publishing.template=../../templates/webhelp-documentation-template --output=../../doc/project-documentation/out
内容的提问来源于stack exchange,提问作者Yashmerino
相关产品推荐
相关产品推荐

