Skip to content

Support dotenv files #277

@kindermax

Description

@kindermax

Currently the only way to run lets with predefined specific env variables is to use sh, for example:

Env script .env.sh

export MY_ENV=123

lets.yaml

In this case MY_ENV exists.

commands:
  run: echo ${MY_ENV}

But the problem that if I want to explicitly tell lets command which env vars I expect, there is only one way using sh

This does not work - it prints ${MY_ENV}

commands:
  env:
    MY_ENV: ${MY_ENV}
  run: echo ${MY_ENV}

This work - it prints 123

commands:
  env:
    MY_ENV: 
      sh: echo ${MY_ENV}
  run: echo ${MY_ENV}

We have two options:

  1. Add env interpolation such as in docker-compose so this will print 123, but the problem is that this requires distinguish between local and interpolated vars. Docker compose uses $$ to access local vars. I do not want to add this right now.
commands:
  env:
    MY_ENV: ${MY_ENV}
  run: echo ${MY_ENV}
  1. Add support for dotenv. This can be implemented in two ways:

First: here we are declaring env and env_file - so env can interpolate vars from file

commands:
  env:
    MY_ENV: ${MY_ENV}
  env_file: .env
  run: echo ${MY_ENV}

Second: or we can just populate env from env_file. This I like most - because it does not requires us to implement interpolation right now, it is just appends env from file to existing env.

Questions:

  1. What priority env_file has ?
  2. Do we need env_file global keyword ?
commands:
  env_file: .env
  run: echo ${MY_ENV}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions