Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env upload via CLI #1612

Open
pythoninthegrass opened this issue Mar 21, 2024 · 2 comments · May be fixed by #1817
Open

.env upload via CLI #1612

pythoninthegrass opened this issue Mar 21, 2024 · 2 comments · May be fixed by #1817
Labels
🚀 feature request New feature or request

Comments

@pythoninthegrass
Copy link

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.

@maidul98 maidul98 added the 🚀 feature request New feature or request label Mar 22, 2024
@abdulhakkeempa
Copy link
Contributor

Hey @maidul98, I would like to work on this feature. Can you assign me this issue?

@quinton11 quinton11 linked a pull request May 12, 2024 that will close this issue
@SimulShift
Copy link

SimulShift commented May 21, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants