-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.backup.sh
executable file
·108 lines (75 loc) · 3.17 KB
/
deploy.backup.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
source ~/.bashrc
AWS_PROFILE="ivanjoz"
AWS_S3="gerp-v2-frontend"
FUNCTION_NAME="jobfinder6-p-app"
PUBLICAR_ASSETS=""
echo "Seleccione acciones a realizar: (Es posible escoger más de 1. Ejemplo: '123')"
echo "Publicar Código ----------------"
echo "[1] Frontend [2] Backend [3] Frontend (Assets) [4] Backup Lib"
echo "Ejecutar Proceso ---------------"
echo "[5] Recrear Tablas [6] Poblar Estructuras [7] Inspeccionar Backend"
read ACCIONES
echo "Obteniendo los últimos cambios del repositorio (GIT PULL)..."
if [[ $ACCIONES == *"1"* || $ACCIONES == *"2"* || $ACCIONES == *"3"* ]]; then
git pull
fi
echo "Usando AWS Profile: $AWS_PROFILE"
export PATH=$HOME/.nvm/versions/node/v20.16.0/bin:$PATH
GO_PATH="go"
if [ -x /usr/local/go/bin/go ]; then
GO_PATH="/usr/local/go/bin/go"
fi
#PUBLICAR FRONTEND
if [[ $ACCIONES == *"1"* ]]; then
echo "=== PUBLICANDO FRONTEND ==="
echo "Enviando archivos a S3: $AWS_S3"
S3_SYNC="s3 sync ./frontend/.output/public"
S3_CP="s3 cp ./frontend/.output/public"
if [[ $ACCIONES != *"x"* ]]; then
npm run build --prefix ./frontend
fi
aws --profile $AWS_PROFILE $S3_SYNC/assets s3://$AWS_S3/assets --size-only --exclude "*" --include "*.js" --content-type application/javascript --delete
aws --profile $AWS_PROFILE $S3_SYNC/assets s3://$AWS_S3/assets --size-only --exclude "*" --include "*.css" --content-type text/css --delete
aws --profile $AWS_PROFILE $S3_SYNC/_build s3://$AWS_S3/_build --size-only --exclude "*" --include "*.js" --content-type application/javascript --delete
aws --profile $AWS_PROFILE $S3_SYNC/_build s3://$AWS_S3/_build --size-only --exclude "*" --include "*.css" --content-type text/css --delete
aws --profile $AWS_PROFILE $S3_CP/sw.js s3://$AWS_S3/sw.js --content-type application/javascript
aws --profile $AWS_PROFILE $S3_CP/manifest.webmanifest s3://$AWS_S3/manifest.webmanifest --content-type application/json
aws --profile $AWS_PROFILE $S3_CP/index.html s3://$AWS_S3/index.html --content-type text/html
if [[ $ACCIONES == *"3"* ]]; then
aws --profile $AWS_PROFILE $S3_SYNC/images s3://$AWS_S3/images --size-only
# aws --profile $AWS_PROFILE $S3_SYNC/icons s3://$AWS_S3/icons --size-only
aws --profile $AWS_PROFILE $S3_SYNC/libs s3://$AWS_S3/libs --size-only
fi
echo "El deploy frontend finalizado!"
fi
#PUBLICAR BACKEND
if [[ $ACCIONES == *"2"* ]]; then
echo "=== PUBLICANDO BACKEND ==="
cd ./cloud
$GO_PATH run . accion=1
echo "El deploy backend-node finalizado!"
fi
#PUBLICAR DB BACKUP BINARY
if [[ $ACCIONES == *"4"* ]]; then
echo "=== PUBLICANDO DB-BACKUP ==="
cd ./db-backup
GOOS=linux GOARCH=arm64 go build -ldflags '-s -w' .
aws --profile $AWS_PROFILE s3 cp ./db-backup s3://$AWS_S3/_bin/db-backup.bin
echo "El deploy del ejecutable finalizó."
fi
#PUBLICAR DB BACKUP BINARY
if [[ $ACCIONES == *"5"* ]]; then
echo "=== RECREANDO TABLAS ==="
cd ./backend
$GO_PATH run . fn-homologate
fi
if [[ $ACCIONES == *"7"* ]]; then
echo "=== COMPILANDO BACKEND ==="
cd ./backend
$GO_PATH build -v .
gsa app
fi
echo "Finalizado!. Presione cualquier tecla para salir"
read
kill -9 $PPID