Skip to content
Snippets Groups Projects
Select Git revision
  • f3668cddeddb3e7ba844b981315cb8961a5a6e0e
  • master default protected
  • maj-readme
  • update-budget-msg-2022
  • share-with-metadata
  • explications-resultats-macros-PLF2022
  • plf_fix
  • benoit-cty-master-patch-87290
  • activate-plf-2021
  • stats
  • switch-plf
  • carto
  • adapt-matomo
  • js-to-ts
  • nbre-part-logic
  • add-nbre-part
  • 1.0.0
17 results

.gitlab-ci.yml

Blame
  • .gitlab-ci.yml 2.16 KiB
    image: node:12
    
    stages:
      - install
      - linting
      - test
      - deploy
    
    cache:
      untracked: true
      # CI_COMMIT_REF_SLUG : The branch or tag name for which project is built.
      key: ${CI_COMMIT_REF_SLUG}
      # TODO : ajouter checksum fichier package.json, mais ne semble pas possible : https://gitlab.com/gitlab-org/gitlab/-/issues/18986
      paths:
        - node_modules/
    
    variables:
      # For Git, to prevent asking for user config
      GIT_EMAIL: gitlabci@gitlab.com
      GIT_AUTHOR_NAME: gitlabci
    
    install:
      stage: install
      script:
        - npm install -g npm@6.13
        - npm install
    
    # linting:
    #   stage: linting
    #   script:
    #     - npm run code:check
    
    test:
      stage: test
      script:
        - npm test
    
    deploy-integ:
      stage: deploy
      script:
       - eval $(ssh-agent -s)
       - ssh-add <(echo "$SSH_PRIVATE_KEY")
       - '[[ -f /.dockerenv ]] && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
       - ssh leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && git config user.email $GIT_EMAIL && git config user.name $GIT_AUTHOR_NAME"
       - ssh leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && git fetch && git checkout -B $CI_COMMIT_REF_NAME $CI_COMMIT_SHA && git pull origin $CI_COMMIT_REF_NAME  && exit"
       - ssh leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && npm install && npm run build && exit"
       - ssh leximpact@$INTEGRATION_IP "systemctl --user restart leximpactclient.service"
      # when: manual
      environment:
        name: integration
    
    
    deploy-prod:
      stage: deploy
      script:
       - eval $(ssh-agent -s)
       - ssh-add <(echo "$SSH_PRIVATE_KEY")
       - '[[ -f /.dockerenv ]] && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
       - ssh leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && git config user.email $GIT_EMAIL && git config user.name $GIT_AUTHOR_NAME"
       - ssh leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && git fetch && git checkout -B $CI_COMMIT_REF_NAME $CI_COMMIT_SHA && git pull origin $CI_COMMIT_REF_NAME  && exit"
       - ssh leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && npm install && npm run build && exit"
       - ssh leximpact@$PRODUCTION_IP "systemctl --user restart leximpactclient.service"
      only:
        - master
      environment:
        name: production