Skip to content
Snippets Groups Projects
Select Git revision
  • 4612e4709a711868125a377104dde1568addd72a
  • master default
  • dockerization
  • staging
  • backup-before-cleaning-repo
  • dockerfiles-pour-maelle
6 results

.gitlab-ci.yml

Blame
  • Forked from an inaccessible project.
    .gitlab-ci.yml 3.67 KiB
    image: node:15
    
    stages:
      - build
      - deploy
    
    ################################################################################
    #####                              BUILD STAGE                             #####
    ################################################################################
    
    build-front:
      stage: build
      only:
        - master
        - staging
      script:
        - cd ./front
        - npm install --only=prod
        - CI=false npm run build
      artifacts:
        paths:
          - front/node_modules/
          - front/build/
    
    ################################################################################
    #####                         PREPROD-DEPLOY STAGE                         #####
    ################################################################################
    
    back-preprod-deploy:
      stage: deploy
      only:
        - staging
      script:
        - "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
        - eval $(ssh-agent -s)
        - ssh-add <(echo "$SSH_PRIVATE_KEY")
        - mkdir -p ~/.ssh
        - chmod 700 ~/.ssh
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
        - echo ${PREPROD_SECRETS} > secrets.js
        - scp secrets.js root@humaviron.cs-campus.fr:~/leaderboard/back/src/secrets.js
        - >
          ssh root@humaviron.cs-campus.fr
          "source ~/.zshrc &&
          cd leaderboard/back &&
          git stash &&
          git checkout staging &&
          git stash &&
          git pull &&
          npm install --only=prod &&
          pm2 delete back-preprod &&
          pm2 start src/index.js --name back-preprod &&
          exit"
    
    front-preprod-deploy:
      stage: deploy
      only:
        - staging
      dependencies:
        - build-front
      script:
        - "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
        - eval $(ssh-agent -s)
        - ssh-add <(echo "$SSH_PRIVATE_KEY")
        - mkdir -p ~/.ssh
        - chmod 700 ~/.ssh
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
        - >
          ssh root@humaviron.cs-campus.fr
          "sudo rm -rf /var/www/preprod/* &&