tools/.gitlab-ci.yml
2018-07-31 08:22:43 +02:00

80 lines
2.1 KiB
YAML

image: node:9.4.0
cache:
paths:
- node_modules/
- .yarn
before_script:
- apt-get update -qq && apt-get install
stages:
- build
- test
- staging
- production
Build:
stage: build
tags:
- node
before_script:
- yarn config set cache-folder .yarn
- yarn install
script:
- npm run build
Test:
stage: test
tags:
- node
before_script:
- yarn config set cache-folder .yarn
- yarn install
script:
# Installs Chrome
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
- apt-get update
- apt-get install google-chrome-stable -y
# Runs the tests.
- npm run test:karma-headless
Deploy to Staging:
stage: staging
tags:
- node
before_script:
# Generates to connect to the AWS unit the SSH key.
- mkdir -p ~/.ssh
- echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
# Sets the permission to 600 to prevent a problem with AWS
# that it's too unprotected.
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- bash ./gitlab-deploy/.gitlab-deploy.staging.sh
environment:
name: staging
# Exposes a button that when clicked take you to the defined URL:
url: http://ec2-13-59-173-91.us-east-2.compute.amazonaws.com:3001
Deploy to Production:
stage: production
tags:
- node
before_script:
# Generates to connect to the AWS unit the SSH key.
- mkdir -p ~/.ssh
- echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
# Sets the permission to 600 to prevent a problem with AWS
# that it's too unprotected.
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- bash ./gitlab-deploy/.gitlab-deploy.prod.sh
environment:
name: production
# Exposes a button that when clicked take you to the defined URL:
url: http://ec2-13-59-173-91.us-east-2.compute.amazonaws.com:81
when: manual