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.

post-receive 1.2KB

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. )
  12. steps=(
  13. "navigate to project…"
  14. "git checkout…"
  15. "backend npm install…"
  16. "building backend…"
  17. "frontend npm install…"
  18. "building frontend…"
  19. "regenerate db data…"
  20. )
  21. SPAN=92
  22. COUNT=0
  23. hr() {
  24. printf "\n"
  25. for i in $(seq 0 $SPAN) ; do
  26. printf $1
  27. done
  28. printf "\n"
  29. }
  30. print_step() {
  31. hr "-"
  32. let step_count=$COUNT+1
  33. printf "* POST-RECEIVE | Step: ${step_count} of ${#steps[@]}: ${1}"
  34. hr "-"
  35. printf "\n"
  36. let COUNT++
  37. }
  38. run() {
  39. # Header line
  40. printf "\n\n"
  41. printf "** SIIMEE **"
  42. hr "="
  43. printf "\nStarting POST-RECEIVE…"
  44. # Body
  45. for step in ${!steps[@]}; do
  46. printf "\n"
  47. print_step "${steps[$step]}"
  48. eval "${commands[$step]}"
  49. done
  50. # Footer line
  51. printf "\n"
  52. hr "="
  53. }
  54. run