GitHub Actions 中的“shell: bash -l {0}”

Hon*_*iao 11 bash shell github-actions

当我使用setup-minicondashell: bash -l {0}时,它在 GitHub Actions 中使用:

\n
jobs:\n  foo:\n    name: Foo\n    runs-on: "ubuntu-latest"\n    defaults:\n      run:\n        shell: bash -l {0}\n
Run Code Online (Sandbox Code Playgroud)\n

当我使用CML时。它只使用shell: bash没有-l {0}.

\n

我在GitHub Actions doc找到了一些解释:

\n
\n

您可以shell使用 将该值设置为模板字符串command [\xe2\x80\xa6options] {0} [..more_options]。GitHub 将字符串的第一个空格分隔的单词解释为命令,并在 处插入临时脚本的文件名{0}

\n
\n

-l不过我还是不太明白和 的作用是什么{0}?对于-l,它是 的参数bash吗?

\n

感谢一些解释!

\n

Von*_*onC 7

这可能与第 128 期有关,其中指出:

我被困了一段时间,因为我的运行命令没有使用登录 bash shell。
所以 conda 环境不活跃。

在 yaml 中警告并推荐类似以下内容会很有帮助:

defaults:
  run:
    shell: bash -l {0}
Run Code Online (Sandbox Code Playgroud)

和:

  • -l确保环境设置正确的登录bash;
  • {0},一个模板占位符,在管道执行时替换为要执行的实际脚本命令。