deploy-parts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. #
  3. # deploy-parts - Deploy parts of an application
  4. #
  5. # usage: deploy-parts --parts "api, app, web"
  6. #
  7. # Parts defaults to "api, app, ui, web". Missing parts are silently ignored.
  8. # Parses keys.json and expands tokens using product.json and pak.json.
  9. # Calls bin/deploy if present, lese docker-deploy-elb if AWS_PROXY is defined, else docker-deploy-instance.
  10. # Invokes deploy script with same args as passed in.
  11. #
  12. function deployParts() {
  13. unset CDPATH
  14. local PARTS="api, app, ui, web"
  15. while [[ $# -gt 0 ]] ; do
  16. arg="$1"
  17. case ${arg} in
  18. --parts)
  19. PARTS="${2}"
  20. shift ; shift
  21. ;;
  22. *)
  23. break
  24. ;;
  25. esac
  26. done
  27. PARTS=$(echo ${PARTS} | tr ',' ' ')
  28. for part in ${PARTS} ; do
  29. [ ! -d "${part}" ] && continue
  30. echo -e "\nDeploying ${PART} ..."
  31. local files=""
  32. for f in CONFIG/keys.json ${part}/CONFIG/keys.json ${part}/product.json pak.json ; do
  33. [ -f ${f} ] && files="${files} ${f}"
  34. done
  35. eval $(paks/assist/json2env ${files})
  36. cd "./${part}"
  37. if [ -f bin/deploy ] ; then
  38. bin/deploy $*
  39. elif [ -f gulpfile.ts -o gulpfile.js -o gulpfile.babel.js ] ; then
  40. gulp deploy $*
  41. elif [ -f main.me ] ; then
  42. me deploy
  43. elif [ -f Makefile ] ; then
  44. make deploy
  45. fi
  46. [ $? != 0 ] && exit 2
  47. cd ..
  48. done
  49. }
  50. deployParts $*