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

Tom Käsler's avatar
Tom Käsler committed
8 9 10 11
# Cache modules in between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
12
    - node_modules/
Tom Käsler's avatar
Tom Käsler committed
13

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

21
ts_lint:
22
  stage: test
23 24 25
  tags:
    - nodejs
  script:
26
    - npm install
27
    - node_modules/tslint/bin/tslint -c tslint.json -p tsconfig.json
28

29
npm_test:
30 31 32 33
  stage: test
  tags:
    - nodejs
  script:
34 35 36
    - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
    - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
    - apt-get -y update
37
    - apt-get -y install --allow-unauthenticated google-chrome-stable
38
    - npm install
39
    - npm test
40

Tom Käsler's avatar
Tom Käsler committed
41 42 43 44 45 46 47
build:
  stage: build
  only:
    - master
  tags:
    - nodejs
  script:
48
    - echo $STAGING_SERVER_ENDPOINTS > src/assets/serverEndpoint.json
49
    - npm install
50
    - npm run build:SSR
51 52 53
    - cd dist
    - node server &
    - sleep 15s
Tom Käsler's avatar
Tom Käsler committed
54 55
  artifacts:
    paths:
Tom Käsler's avatar
Tom Käsler committed
56
      - dist
Tom Käsler's avatar
Tom Käsler committed
57

58
generate_assets:
59 60 61 62 63
  stage: assets
  only:
    - master
  tags:
    - nodejs
Tom Käsler's avatar
Tom Käsler committed
64 65
  dependencies:
    - build
66 67 68 69
  script:
    - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
    - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
    - apt-get -y update
Tom Käsler's avatar
Tom Käsler committed
70
    - apt-get -y install --allow-unauthenticated google-chrome-stable imagemagick libpng-dev zlib1g-dev clang
Tom Käsler's avatar
Tom Käsler committed
71
    - export CHROME_BIN=`whereis google-chrome | cut -d " " -f 2`
72
    - npm install
73
    - cd dist/browser/assets/jobs
74
    - node --experimental-modules GenerateImages.mjs --command=generateLogoImages
75
    - node --experimental-modules GenerateImages.mjs --command=generateFrontendPreview --host=http://localhost:4000
76 77
    - node GenerateMetaNodes.js --command=generateLinkImages --baseUrl=https://staging.arsnova.click
    - node GenerateMetaNodes.js --command=generateManifest --baseUrl=https://staging.arsnova.click
78 79 80
  artifacts:
    paths:
      - dist
81

Tom Käsler's avatar
Tom Käsler committed
82 83 84 85 86
deploy:
  stage: deploy
  only:
    - master
  tags:
87
    - rsync
Tom Käsler's avatar
Tom Käsler committed
88
  dependencies:
Tom Käsler's avatar
Tom Käsler committed
89
    - generate_assets
Tom Käsler's avatar
Tom Käsler committed
90
  script:
Tom Käsler's avatar
Tom Käsler committed
91
    - chmod -R a+rX,ug+w .
Tom Käsler's avatar
Tom Käsler committed
92
    - eval $(ssh-agent -s)
Tom Käsler's avatar
Tom Käsler committed
93 94
    - mkdir ~/.ssh
    - ssh-keyscan "$STAGING_FRONTEND_URL" >> ~/.ssh/known_hosts
Tom Käsler's avatar
Tom Käsler committed
95
    - ssh-add <(echo "$STAGING_SSH_PRIVATE_KEY")
Tom Käsler's avatar
Tom Käsler committed
96
    - rsync -rltgoDqv --delete -e "ssh" dist/* "$STAGING_FRONTEND_SCP_URL"
97
    - ssh $STAGING_SSH 'touch /home/arsnova/arsnova.click-v2/frontend/deploy.touch'