image: node:16.14.2 stages: - Build + Test - Dev - Stage - Production Build: stage: Build + Test allow_failure: false script: - npx wappi build .unit_tests_step: stage: Build + Test allow_failure: true script: - npx wappi test environment: name: Testing Unit Tests Main: only: - main extends: - .unit_tests_step Unit Tests Branch: except: - main extends: - .unit_tests_step Lint: stage: Build + Test allow_failure: true before_script: - npm i eslint script: - npm run gitLabLint .deploy_step: only: - main when: manual allow_failure: false before_script: #generate ssh key - mkdir -p ~/.ssh - echo -e "$EC2_SERVICES_PEM" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - apt-get update --yes - apt-get --yes --force-yes install rsync - npm install prisma script: - if [ -z ${EC2_PUBLIC_IPV4_DNS+x} ]; then echo "FAILED - NO EC2 instance set up"; exit 1; else echo "EC2 instance set to - $EC2_PUBLIC_IPV4_DNS"; fi - bash @Core/Scripts/createEnvFile.sh - ls -al - npm run build - ls -al - rsync --delete -avze "ssh -i ~/.ssh/id_rsa" ./dist/* ubuntu@${EC2_PUBLIC_IPV4_DNS}:~/ - ls -al - ssh ubuntu@${EC2_PUBLIC_IPV4_DNS} -tt 'bash -s' < ./@Core/Scripts/restartEC2Server.sh # DATABASE DEPLOYMENT - npx prisma migrate deploy # Dev Code Deploy Dev: stage: Dev when: always extends: - .deploy_step environment: name: Dev # Stage # Code & DB Deploy Stage: # stage: Stage # extends: # - .deploy_step # environment: # name: Stage #Production stage Code & DB Deploy Production: stage: Production extends: - .deploy_step environment: name: Production after_script: - "[ $CI_JOB_STATUS == 'success' ] && node @Core/Scripts/slackDBDeployNotifier.ts" - node @Core/Scripts/slackDeploymentNotifier.ts