stages: - setup - lint - test - build - publish - deploy install: image: node:12 stage: setup script: - npm ci artifacts: paths: - node_modules expire_in: 1 week es:lint: image: node:12 needs: ["install"] stage: lint script: - npm run lint:es sass:lint: image: node:12 needs: ["install"] stage: lint script: - npm run lint:sass build: image: node:12 needs: ["install"] stage: lint script: - API_URL=http://web.sik.party:8000/api npm run build # test:unit: # image: node:12 # stage: test # script: # - npm run test:unit test:e2e: image: circleci/node:12-browsers needs: ["install"] stage: test only: - master script: - API_URL=http://web.sik.party:8000/api npm run test:e2e build: image: node:12 needs: ["install"] stage: build script: - npm run build dependencies: - install artifacts: paths: - dist expire_in: 1 week publish:dev: stage: publish image: docker:stable needs: ["build", "test:e2e", "es:lint", "sass:lint"] services: - docker:stable-dind only: - master script: - docker info - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker build . -t "$IMAGE_NAME":latest - docker push "$IMAGE_NAME":latest publish:prod: stage: publish image: docker:stable services: - docker:stable-dind only: - production script: - docker info - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker build . -f Dockerfile.prod -t "$IMAGE_NAME":prod - docker push "$IMAGE_NAME":prod 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 "docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY" - ssh $DEV_SSH_USER@$DEV_SSH_HOST "bash ~/deployment-frontend/deploy_dev.sh \"$IMAGE_NAME:latest\"" deploy:prod: stage: deploy image: docker:stable only: - production environment: name: production url: sika.sik.party when: manual variables: DOCKER_HOST: $CI_DOCKER_HOST DOCKER_TLS_VERIFY: 1 before_script: - mkdir -p ~/.docker - echo "$TLSCACERT" > ~/.docker/ca.pem - echo "$TLSCERT" > ~/.docker/cert.pem - echo "$TLSKEY" > ~/.docker/key.pem - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" script: - docker stack deploy --with-registry-auth -c stack-compose.yml "$SERVICE_NAME" after_script: - docker logout "$CI_REGISTRY"