-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-secrets.sh
More file actions
executable file
·40 lines (31 loc) · 1.19 KB
/
sync-secrets.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Configuración
PROJECT_NAME="bitmeet"
ENV_FILE=".env"
# Comprobar si existe el archivo .env
if [ ! -f "$ENV_FILE" ]; then
echo "Error: El archivo $ENV_FILE no existe."
exit 1
fi
echo "🚀 Iniciando subida de secretos para el proyecto: $PROJECT_NAME"
# Leer el archivo .env línea por línea
while IFS= read -r line || [ -n "$line" ]; do
# Ignorar líneas vacías y comentarios
[[ -z "$line" || "$line" =~ ^# ]] && continue
# Extraer clave y valor (soporta valores con el signo =)
KEY=$(echo "$line" | cut -d '=' -f 1)
VALUE=$(echo "$line" | cut -d '=' -f 2-)
# Limpiar posibles comillas en el valor
VALUE=$(echo "$VALUE" | sed -e 's/^"//' -e 's/"$//' -e "s/^'//" -e "s/'$//")
if [ -n "$KEY" ]; then
echo "📤 Subiendo: $KEY..."
# Usamos printf para evitar problemas con caracteres especiales y lo pasamos por stdin a wrangler
printf "%s" "$VALUE" | npx wrangler pages secret put "$KEY" --project-name "$PROJECT_NAME"
if [ $? -eq 0 ]; then
echo "✅ $KEY subido correctamente."
else
echo "❌ Error al subir $KEY."
fi
fi
done < "$ENV_FILE"
echo "✨ Proceso finalizado."