Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`shell: bash -l {0}` in GitHub Actions

When I use setup-miniconda, it uses shell: bash -l {0} in GitHub Actions:

jobs:
  foo:
    name: Foo
    runs-on: "ubuntu-latest"
    defaults:
      run:
        shell: bash -l {0}

When I use CML. It only uses shell: bash without -l {0}.

I found some explanation at GitHub Actions doc:

You can set the shell value to a template string using command […options] {0} [..more_options]. GitHub interprets the first whitespace-delimited word of the string as the command, and inserts the file name for the temporary script at {0}.

However, I am still not clear what are the functions of -l and {0}? For -l, is it a parameter of bash?

Appreciate for some explanations!

like image 274
Hongbo Miao Avatar asked Apr 07 '26 12:04

Hongbo Miao


1 Answers

That could be linked to issue 128 which states:

I got stuck for a while because my run commands were not using a login bash shell.
So the conda environment was not active.

Would be helpful to warn about that and recommend something like the following in the yaml:

defaults:
  run:
    shell: bash -l {0}

With:

  • -l to insure a login bash, where the environment is correctly set;
  • {0}, a template placeholder, replaced at pipeline execution time by the actual script command to execute.
like image 62
VonC Avatar answered Apr 10 '26 02:04

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!