.gitlab-ci.yml 1.87 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
  stage: test
30
  allow_failure: true
Tom Käsler's avatar
Tom Käsler committed
31 32 33
  tags:
    - nodejs
  script:
34
    - npm install
35
    - node_modules/mocha/bin/mocha --opts src/tests/mocha.opts
Tom Käsler's avatar
Tom Käsler committed
36

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

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

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"
89
    - ssh $NEW_PRODUCTION_SSH 'touch /home/arsnova/arsnova.click-v2-beta/backend/deploy.touch'
Tom Käsler's avatar
Tom Käsler committed
90