Add push_env config

This setting allows you to automatically push env files when deploying.
The default is not to push any files, but you can set it to `all`,
`clear` or `secret` to push the relevant files.

The most useful setting is `clear` which will push the clear env files
every time you deploy.

In addition you can choose the env_type to push when calling
`kamal env push` directly:

```
kamal env push --env-type clear
kamal env push --env-type secret
kamal env push --env-type all # same as kamal env push
```
This commit is contained in:
Donal McBreen
2024-03-06 09:39:30 +00:00
parent 1fa25200cc
commit 49ce64de87
8 changed files with 168 additions and 34 deletions

View File

@@ -33,3 +33,4 @@ accessories:
roles:
- web
stop_wait_time: 1
push_env: clear

View File

@@ -7,6 +7,7 @@ class MainTest < IntegrationTest
assert_remote_env_file "CLEAR_TOKEN=4321", :clear
assert_remote_env_file "SECRET_TOKEN=1234", :secret
remove_local_env_file
remove_remote_env_file :clear
first_version = latest_app_version
@@ -15,6 +16,7 @@ class MainTest < IntegrationTest
kamal :deploy
assert_app_is_up version: first_version
assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "post-deploy"
assert_remote_env_file "CLEAR_TOKEN=4321", :clear
second_version = update_app_rev
@@ -70,6 +72,10 @@ class MainTest < IntegrationTest
deployer_exec("rm .env")
end
def remove_remote_env_file(env_type)
docker_compose("exec vm1 cat /root/.kamal/env/roles/app-web-#{env_type}.env")
end
def assert_remote_env_file(contents, env_type)
assert_equal contents, docker_compose("exec vm1 cat /root/.kamal/env/roles/app-web-#{env_type}.env", capture: true)
end