github-actions - GitHub 操作:运行 if
问题描述
我正在尝试为 GitHub Actions 设置自定义操作,目前这就是我所拥有的:
name: 'Install Dependencies'
inputs:
os:
description: 'The OS to fetch the dependencies for'
required: True
runs:
using: "composite"
steps:
- run: echo I am a test
shell: bash
if: startsWith(os, 'Linux')
我想要做的是最终拥有一堆不同的 shell 脚本,这些脚本专为特定操作系统完成工作,因此在我的操作中,我想根据os
传递给它的参数选择适当的脚本。
当我调用如上所示的操作时,我得到Unexpected value 'if'
. run
所以我的问题是:如果满足条件,我怎样才能运行执行命令?
解决方案
最简单的选择可能是为您的脚本使用命名约定并使用操作系统的名称运行调用它们:
myscript.$(os).sh
推荐阅读
- uproot - 将 ROOT 文件读取到数据帧:uproot 比 root_numpy 的 tree2array 慢
- android - 华为广告套件横幅广告返回错误代码1
- java - 如何在javaFX中保持场景状态
- java - 从侦听器将数据写入 txt 文件
- firebase - Firestore 规则:对象上的属性未定义
- firebase - 只允许付费用户写入特定字段?
- image - 当键盘弹出时如何隐藏图像小部件?
- javascript - 正则表达式在任何非字母之前获取字符串
- reactjs - 将字符串变量 prop 传递给 useQuery 函数
- c# - 如何跳到csv文件csvhelper c#的最后一个表/数据集