Files
web2.0-frontend/.gitlab-ci.yml
T
2018-08-21 22:31:13 +03:00

95 lines
2.1 KiB
YAML

stages:
- setup
# - test
- lint
- publish
- deploy
cache:
paths:
- node_modules/
setup:
image: node
stage: setup
script:
- npm ci
# test:unit:
# image: node
# stage: test
# script:
# - npm run test:unit
# test:e2e:
# image: node
# stage: test
# script:
# - npm run test:e2e
ts:lint:
image: node
stage: lint
script:
- npm run lint:ts
sass:lint:
image: node
stage: lint
script:
- npm run lint:sass
publish:
stage: publish
image: docker:latest
only:
- master
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:3000
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.yml $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment-frontend/docker-compose.yml
- scp .deploy_dev.sh $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment-frontend/deploy_dev.sh
- ssh $DEV_SSH_USER@$DEV_SSH_HOST "bash ~/deployment-frontend/deploy_dev.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"