如何在 github 操作步骤中运行 if else if ?我正在寻找一种在一步中执行多个 if 条件的选项?
最佳答案
如果不使用一些代码,您就无法在 github 操作工作流程作业步骤中 native 运行 if/else if(还?)。
例如,您最终可以使用 bash
来实现您想要的,如下所示:
- run: |
if [ ${{ github.ref }} == 'refs/heads/main' ]; then
echo "is MAIN branch"
elif [ ${{ github.ref }} == 'refs/heads/dev' ]; then
echo "is DEV branch"
else
echo "is neither MAIN nor DEV branch"
fi
shell: bash
关于github - 如何在 github actions 中执行 if else if 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72872929/