Skip to content

Dynamic .env file #434

Closed
Closed

Description

@g5becks

This may be possible already and I am unaware of it, but what I would like to be able to do is set the dotenv file based on an environment variable.
E.G.

version: "3"

env:
  NODE_ENV: echo $($NODE_ENV)

dotenv: ["./packages/server/.env.{{.NODE_ENV}}"]

This would enable more dynamic variables for my tasks as opposed to writing separate taskfiles and including them.

Thanks.

Activity

  1. badele commented on Mar 17, 2021

    @badele

    In the meantime, you can use this workaround

    # I assume that NODE_ENV is in shell variable 
    set -o allexport; source ./packages/server/.env.${NODE_ENV}; set +o allexport
    task target
    
  2. badele commented on Mar 18, 2021

    @badele

    The best feature would be have a taskfile to be able to use variables on any yaml section (from vars, env or minima environment vars)

  3. andreynering commented on Jun 5, 2021

    @andreynering
    Member

    This was just implemented at 08265ed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions