Skip to content

Instantly share code, notes, and snippets.

@ChaboCode
Created May 21, 2020 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaboCode/c475970a67407dc2d685657bac3a9cf0 to your computer and use it in GitHub Desktop.
Save ChaboCode/c475970a67407dc2d685657bac3a9cf0 to your computer and use it in GitHub Desktop.
change=0
deploy=0
while IFS= read -r line; do
uri="$line"
done < <(grep -v "^//.*" ./client/src/server.js)
case $uri in
"export default 'https://deploy.uri'")
mode=1
echo "Estas en modo de despliegue"
;;
"export default 'http:/dev.uri'")
mode=2
echo "Estas en modo de desarrollo"
;;
esac
args=`getopt cd $*`
set -- $args
for i; do
case $i in
'-c') change=1 ;;
'-d') deploy=1 ;;
esac
done
change() {
case $mode in
1) modeto="desarollo"; urito="export default 'http://dev.uri'\n// export default 'https://deploy.uri'" ;;
2) modeto="despliegue"; urito="// export default 'http://dev.uri'\nexport default 'https://deploy.uri'" ;;
esac
read -e -p "Deseas cambiar al modo de $modeto?[s/N]" pmpt
case ${pmpt:-"n"} in
's'|'S')
echo "Cambiando"
echo -ne $urito > 'route/to/server/file'
;;
'n'|'N') echo "Abortando" ;;
esac
}
if [ $change = 1 ]; then
change
fi
deploy() {
if [ $mode = 2 ]; then
echo "ADVERTENCIA: Estas en modo de desarrollo"
change
deploy
fi
read -e -p "Deseas desplegar los cambios?[s/N]" pmpt
case ${pmpt:-"n"} in
's'|'S')
echo "Desplegando"
git push #or whatever you do to deploy
echo "Cambios desplegados. Asegurate de haber actualizado los cambios en el repositorio remoto."
;;
'n'|'N') echo "Abortando" ;;
esac
}
if [ $deploy = 1 ]; then
deploy
fi
@ChaboCode
Copy link
Author

This is a file made to automate changes on servers for web apps. I noticed that once i was ready to deploy, all the links are for the development server. So what i made is that i have a file that exports an uri, and when i need that uri, i only change the uri on the uri file. The job os this file is to help to change from the dev server to de deployment server, and it alerts when you try to deploy with the development uri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment