stages: # 分段
- deploy-sit
- deploy-prod
cache: # 缓存
paths:
- node_modules
before_script:
- sshpass -p $PASSWORD ssh $USERNAME@$IP -o StrictHostKeyChecking=no
- cd ~
- ([ -d /root/backend-cicd/app/public ] && mv /root/backend-cicd/app/public /root/public) || echo
- rm -rf ./backend-cicd
- git clone git@192.168.235.129:zhongs/backend-cicd.git
- ([ -d /root/public ] && mv /root/public /root/backend-cicd/app/public) || echo
- cd ./backend-cicd
deploy-sit-job:
tags:
- backend-cicd
only:
- sit
stage: deploy-sit
script:
- pwd
- git checkout sit
- cnpm install
- npm run stop
- npm run start-sit
- exit
deploy-prod-job:
tags:
- backend-cicd
only:
- prod
stage: deploy-prod
script:
- pwd
- git checkout prod
- cnpm install
- npm run stop
- npm run start-prod
- exit