Add CI and CD

This commit is contained in:
Aarni Halinen
2018-07-24 20:11:06 +03:00
parent 7b17d9d0e3
commit ec8ee95790
3 changed files with 116 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
stages:
- test
- lint
- publish
- deploy
test:unit:
image: node:7.10.0
stage: test
before_script:
- npm install
script:
- npm run test:unit
test:e2e:
image: node:7.10.0
stage: test
before_script:
- npm install
script:
- npm run test:e2e
ts:lint:
image: node:7.10.0
stage: lint
before_script:
- npm install
script:
- npm run lint:ts
sass:lint:
image: node:7.10.0
stage: lint
before_script:
- npm install
script:
- npm run lint:sass
publish:
stage: publish
image: docker:latest
only:
- develop
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY_URL
script:
- docker build . -t "$IMAGE_NAME"
- docker push "$IMAGE_NAME"
deploy_dev:
stage: deploy
image: alpine:latest
environment:
name: dev
url: http://web.sik.party:8080
only:
- master
before_script:
- pwd
- apk add --update openssh
- ssh -V
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- scp docker-compose-frontend.yml $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment/docker-compose-frontend.yml
- scp .deploy_dev-frontend.sh $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment/deploy_dev-frontend.sh
- ssh $DEV_SSH_USER@$DEV_SSH_HOST "bash ~/deployment/deploy_dev-frontend.sh \"$IMAGE_NAME\""
# deploy_production:
# stage: deploy
# image: alpine:latest
# environment:
# name: production
# url: https://sika.sahkoinsinoorikilta.fi
# when: manual
# only:
# - master
# before_script:
# - pwd
# - apk add --update openssh
# - ssh -V
# - mkdir -p ~/.ssh
# - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
# - chmod 600 ~/.ssh/id_rsa
# - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# script:
# - ssh $PROD_SSH_USER@$PROD_SSH_HOST "zsh ~/deploy-frontend.sh"