Created
July 29, 2025 13:05
-
-
Save sander3/3b7c044e307515dda5ee1a674af49d83 to your computer and use it in GitHub Desktop.
Replace Doppler config with local .env
This file contains hidden or 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
# 0) Set your target | |
PROJECT=project | |
CONFIG=local_personal | |
ENVFILE=./.env | |
# 1) List current keys in the Doppler config | |
doppler secrets download -p "$PROJECT" -c "$CONFIG" --no-file --format json \ | |
| jq -r 'keys[]' | sort > /tmp/doppler_keys.txt | |
# 2) List keys present in your .env (handles optional `export KEY=...`, ignores comments) | |
grep -E '^[[:space:]]*(export[[:space:]]+)?[A-Za-z_][A-Za-z0-9_]*=' "$ENVFILE" \ | |
| sed -E 's/^[[:space:]]*(export[[:space:]]+)?([A-Za-z_][A-Za-z0-9_]*)=.*/\2/' \ | |
| sort > /tmp/file_keys.txt | |
# 3) (Dry‑run) Show which keys will be removed from Doppler | |
echo "Keys that will be deleted:" | |
comm -23 /tmp/doppler_keys.txt /tmp/file_keys.txt | |
# 4) Delete keys that aren't in your .env | |
comm -23 /tmp/doppler_keys.txt /tmp/file_keys.txt \ | |
| xargs -r -n1 -I{} doppler secrets delete -p "$PROJECT" -c "$CONFIG" -y {} | |
# 5) Upload your .env to create/update the remaining keys | |
doppler secrets upload "$ENVFILE" -p "$PROJECT" -c "$CONFIG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment