github - 如何在 github actions 中执行 if else if 条件

标签 github github-actions

如何在 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/

相关文章:

reactjs - 为什么每次从 github pull 时都必须删除 node_modules 文件夹

github - 如何在 GitHub 工作流程中安排和推送/拉取请求事件?

git - 配置 Git 客户端,例如 GitHub for Windows,不要求身份验证

git - GitHub Build容器镜像出现错误

github-actions - 尝试发布我的 Github 页面时出现构建错误

github-actions - 无法使用 GitHub Actions 在 ECS 中注册任务定义

azure - 从 Github 操作工作流访问私有(private)或受防火墙保护的 Azure 容器注册表

github - GitHub 操作的官方徽章

ios - Xcode 6.2 不会加载远程 git repos

Git:master/develop/feature 分支 merge 提交