Use the $usage variables in the [env] section for dynamic environments #6767
Replies: 2 comments 1 reply
-
|
I think you can use the [tasks."deploy"]
usage = '''
arg "<environment>" "Environment name"
'''
run = """
MISE_ENV_FILE=.env.$usage_environment pnpm deploy
""" |
Beta Was this translation helpful? Give feedback.
-
|
I'd actually like this for a different reason: sometimes, we may want to use an argument to set an environment variable directly, and there isn't a shell-independent way to do this. For example, I want to pass an env var named [tasks.build]
usage = '''
option "--tag <tag>"
'''
run = "TAG=$usage_tag docker buildx bake"but this wouldn't work on Windows. I assume it would be possible to use a separate [tasks.build]
usage = '''
option "--tag <tag>"
'''
env.TAG = { value = '{{ env.usage_tag }}', usage = true }
run = "docker buildx bake"(This syntax would be rather verbose, but it's better than nothing. I assume that this feature cannot be default behavior because the usage args can be set by env vars, but it would be even nicer if we could just write |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice to use the $usage variables when trying to set environment variables or file references. This would allow a user to have multiple dotenv files like
.env.local,.env.dev,.env.staging, etc. This would allow the user or ci to only run:mise deploy <env>.Here are a few examples:
Since there is an option to wait until the tools are initialized, it might make sense to do this:
env.'_'.file = { path = ".env.$usage_environment", tools = true }Or maybe add another similar option for usage?
env.'_'.file = { path = ".env.$usage_environment", usage = true }Beta Was this translation helpful? Give feedback.
All reactions