You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. REPO="/opt/staging/siimee.git"
  3. commands=(
  4. "cd ${REPO}"
  5. "git --git-dir=${REPO} --work-tree=${REPO} checkout master -f"
  6. "cd ${REPO}/backend && rm -f ${REPO}/backend/package-lock.json && npm install"
  7. "echo no build needed!"
  8. "cd ${REPO}/frontend && rm -f ${REPO}/frontend/package-lock.json && npm install"
  9. "npm run build"
  10. # "cd ${REPO}/backend && npm run generate && npm run reseed"
  11. "pm2 restart siimee_backend -i -1 -n siimee_backend"
  12. )
  13. steps=(
  14. "navigate to project…"
  15. "git checkout…"
  16. "backend npm install…"
  17. "building backend…"
  18. "frontend npm install…"
  19. "building frontend…"
  20. # "regenerate db data…"
  21. "start-up…"
  22. )
  23. SPAN=80
  24. COUNT=0
  25. hr() {
  26. printf "\n"
  27. for i in $(seq 0 $SPAN) ; do
  28. printf $1
  29. done
  30. printf "\n"
  31. }
  32. print_step() {
  33. hr "-"
  34. let step_count=$COUNT+1
  35. printf "* POST-RECEIVE | Step: ${step_count} of ${#steps[@]}: ${1}"
  36. hr "-"
  37. printf "\n"
  38. let COUNT++
  39. }
  40. run() {
  41. # Header line
  42. printf "\n\n"
  43. printf "** SIIMEE **"
  44. hr "="
  45. printf "\nStarting POST-RECEIVE…"
  46. # Body
  47. for step in ${!steps[@]}; do
  48. printf "\n"
  49. print_step "${steps[$step]}"
  50. eval "${commands[$step]}"
  51. done
  52. # Footer line
  53. printf "\n"
  54. hr "="
  55. }
  56. run