Facebook
From Reuben M, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 531
  1. image: node:12.16.3
  2.  
  3. stages:
  4.   - tests
  5.   - deploy
  6.  
  7. before_script:
  8.   - apt-get update -qq
  9.  
  10. run_tests:
  11.   stage: tests
  12.   script:
  13.     # - npm i npm@latest -g # this can be commented back in later, at the moment this takes > 30s
  14.     - npm i
  15.     - npm run test-with-coverage
  16.     - npx nyc report --reporter=text-summary
  17.   coverage:
  18.     '/Statements.*?(\d+(?:\.\d+)?)%/'
  19.   artifacts:
  20.     when: always
  21.     paths:
  22.       # save coverage results
  23.       - coverage
  24.     expire_in: 10 days
  25.   only:
  26.     - master
  27.  
  28. deploy_dev:
  29.   stage: deploy
  30.   before_script:
  31.     - echo "I am preparing to copy the SSH key"
  32.     # Setup SSH deploy keys
  33.     - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  34.     - eval $(ssh-agent -s)
  35.     - ssh-add <(echo "$SSH_PRIVATE_KEY")
  36.     - mkdir -p ~/.ssh
  37.     - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  38.   environment:
  39.     name: dev
  40.     url: dev.22d2.net
  41.   script:
  42.     - ssh [USER]@[SERVER-HOST] "sh dev-deploy.sh"
  43.   only:
  44.     - master
  45.  
  46. deploy_prod:
  47.   stage: deploy
  48.   before_script:
  49.     - echo "I am preparing to copy the SSH key"
  50.     # Setup SSH deploy keys
  51.     - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  52.     - eval $(ssh-agent -s)
  53.     - ssh-add <(echo "$SSH_PRIVATE_KEY")
  54.     - mkdir -p ~/.ssh
  55.     - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  56.   environment:
  57.     name: production
  58.     url: 22d2.net
  59.   script:
  60.     - ssh [USER]@[SERVER-HOST] "sh prod-deploy.sh"
  61.   only:
  62.     - release/production
  63.