Set an environment variable to working directory

Could I get some :eyes_flippy: on trying to get env-variables to work within the working-directory
The following works

     run: |
       echo "HELLO"
     working-directory: ./base

This does not work:

        base_directory: ./base
      run: |
        echo "HELLO"
      working-directory: $base_directory

But when I pass in an env var it returns Error: No such file or directory
I’ve tried the following:

$base_directory from workflow syntax

What do you mean by “pass in an env var”? Do you want to set working-directory to the content of an environment variable?

Yes I want to set the working directory to environment variable.

edit: I added the snippet of the yaml that i’ve tried that is not working. Forgot to add it in the initial post.

Thanks, I see. Unfortunately that’s not going to work, the documentation on the env context says this:

You can only use the env context in the value of the with and name keys, or in a step’s if conditional.

There’s no such remark on the steps context, so maybe you could use a step output? I haven’t tried that myself, though.

So I figured it out after days of multiple trial and errors.
We can do:

working-directory: ${{env.base_directory}}

1 Like

Nice, glad that works, even if the documentation says otherwise! :grinning_face_with_smiling_eyes: