.gitlab-ci.yml 1.81 KB
Newer Older
Tom Käsler's avatar
Tom Käsler committed
1
stages:
2
  - install
Tom Käsler's avatar
Tom Käsler committed
3
  - test
4
  - build
Tom Käsler's avatar
Tom Käsler committed
5
  - deploy
6
  - deploy-beta
Tom Käsler's avatar
Tom Käsler committed
7

8
cache:
Tom Käsler's avatar
Tom Käsler committed
9
  key: ${CI_COMMIT_REF_SLUG}
10
  paths:
Tom Käsler's avatar
Tom Käsler committed
11
    - node_modules/
12

13 14 15 16 17
install_node_modules:
  stage: install
  tags:
    - nodejs
  script:
18
    - npm install
Tom Käsler's avatar
Tom Käsler committed
19

20 21 22 23 24
ts_lint:
  stage: test
  tags:
    - nodejs
  script:
Tom Käsler's avatar
Tom Käsler committed
25
    - npm install
26 27 28
    - node_modules/tslint/bin/tslint -c tslint.json -p tsconfig.json

npm_test:
Tom Käsler's avatar
Tom Käsler committed
29 30 31 32
  stage: test
  tags:
    - nodejs
  script:
33
    - npm install
Christopher Mark Fullarton's avatar
Christopher Mark Fullarton committed
34
    - node_modules/nyc/bin/nyc.js --reporter=text node_modules/mocha/bin/mocha --opts src/tests/mocha.opts
Tom Käsler's avatar
Tom Käsler committed
35

36 37 38 39
build:
  stage: build
  only:
    - master
40
    - beta
41 42 43
  tags:
    - nodejs
  script:
Tom Käsler's avatar
Tom Käsler committed
44
    - npm install
45 46 47
    - export NODE_ENV='production'
    - export ARSNOVA_CLICK_BACKEND_PORT_INTERNAL='3000'
    - export ARSNOVA_CLICK_BACKEND_ROUTE_PREFIX='/backend'
48
    - export LEADERBOARD_ALGORITHM='PointBased'
49
    - npm run build:PROD
Tom Käsler's avatar
Tom Käsler committed
50
    - cp package.json dist
51 52 53 54
  artifacts:
    paths:
      - dist

Tom Käsler's avatar
Tom Käsler committed
55 56 57 58 59
deploy:
  stage: deploy
  only:
    - master
  tags:
Tom Käsler's avatar
Tom Käsler committed
60
    - rsync
Tom Käsler's avatar
Tom Käsler committed
61 62 63 64 65
  dependencies:
    - build
  script:
    - chmod -R a+rX,ug+w .
    - eval $(ssh-agent -s)
Tom Käsler's avatar
Tom Käsler committed
66
    - mkdir ~/.ssh
67
    - ssh-keyscan "$STAGING_BACKEND_URL" >> ~/.ssh/known_hosts
Tom Käsler's avatar
Tom Käsler committed
68
    - ssh-add <(echo "$STAGING_SSH_PRIVATE_KEY")
Tom Käsler's avatar
Tom Käsler committed
69
    - rsync -rltgoDqv --delete -e "ssh" dist/* "$STAGING_BACKEND_SSH_URL"
Tom Käsler's avatar
Tom Käsler committed
70
    - ssh $NEW_PRODUCTION_SSH 'touch /home/arsnova/arsnova.click-v2/backend/deploy.touch'
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

deploy-beta:
  stage: deploy-beta
  only:
    - beta
  tags:
    - rsync
  dependencies:
    - build
  script:
    - chmod -R a+rX,ug+w .
    - eval $(ssh-agent -s)
    - mkdir ~/.ssh
    - ssh-keyscan "$STAGING_BACKEND_URL" >> ~/.ssh/known_hosts
    - ssh-add <(echo "$STAGING_SSH_PRIVATE_KEY")
    - rsync -rltgoDqv --delete -e "ssh" dist/* "$BETA_BACKEND_SSH_URL"
87
    - ssh $NEW_PRODUCTION_SSH 'touch /home/arsnova/arsnova.click-v2-beta/backend/deploy.touch'
Tom Käsler's avatar
Tom Käsler committed
88