infisical
infisical copied to clipboard
.env upload via CLI
Feature description
Would like to to upload the .env file with the infisical cli. Currently working on a tiny shell script to read the .env as an array and pass that to infisical secrets set "$env_vars_str" --env new-prod
but it's hackish and it would be nice if there was an option to match the web console's drag and drop functionality
Why would it be useful?
Server admins and devs don't spend a lot of time in the web console. Nice alternative to drag and drop GUI option.
Additional context
Briefly spoke with Vlad on Slack.
Hey @maidul98, I would like to work on this feature. Can you assign me this issue?
Incase anyone wants a bash script to automate it in the meantime, I made this little tool. First argument is path to .env file second argument is the environment as in:
upload_to_infisical.sh .env dev
#!/bin/bash
# Check if the file path and environment arguments are provided
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 path_to_env_file environment"
exit 1
fi
# Path to your .env file from the first argument
ENV_FILE="$1"
# Environment from the second argument
ENV="$2"
# Check if the file exists
if [ ! -f "$ENV_FILE" ]; then
echo "File not found: $ENV_FILE"
exit 1
fi
# Read each line in the .env file
while IFS= read -r line || [ -n "$line" ]; do
# Skip empty lines and lines starting with '#'
if [ -n "$line" ] && [ "${line:0:1}" != "#" ]; then
# Set the secret in Infisical
infisical secrets set "$line" --env "$ENV"
fi
done < "$ENV_FILE"