Last active
December 2, 2023 16:18
-
-
Save nSimonFR/8467644bb56020274d7593ba6f549965 to your computer and use it in GitHub Desktop.
Generate secrets.json from a .env and uploads them to wrangler via bulk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
# Exports .env to .env.json and sends them to wrangler secret | |
# Generated by ChatGPT (But heavily human-corrected, it's almost as bad at regex as humans) | |
# | |
# Assumes you use gnused, warning for macOS users ! | |
# | |
# MIT License - nSimon.fr | |
## | |
echo '{' > .env.json | |
cat .env | grep '^[A-z -_]*=.*$' | sed "s/ //g" | sed "s/'//g" | sed "s/\"//g" | while IFS='=' read -r key value; do | |
echo "\"$key\": \"$value\"," >> .env.json | |
done | |
sed -i '$ s/,$//' .env.json | |
echo '}' >> .env.json | |
wrangler secret:bulk .env.json | |
rm .env.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment