.gitlab-ci.yml 1.92 KB
Newer Older
1
image: node:10-stretch
2 3
services:
    - postgres:10
4

5 6 7 8 9 10 11 12
variables:
    POSTGRES_DB: 'form-creator'
    POSTGRES_HOST: 'postgres'
    PGPASSWORD: '123mudar'
    POSTGRES_PASSWORD: '123mudar'
    POSTGRES_USER: 'runner'
    POSTGRES_PASSWORD: '123mudar'
    POSTGRES_PORT: 5432
13 14 15
    image_version: ''
    DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5000/c3sl/simmctic-form-creator-api'

16 17 18 19 20 21
cache:
    paths:
        - node_modules

stages:
    - test
22 23
    - build
    - deploy
24 25 26

run_test:
    stage: test
27 28 29 30 31 32 33 34 35 36 37 38 39
    before_script:
      - apt-get update -q -y
      - apt-get install wget gnupg -y
      - echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
      - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
      - apt-get update -q -y
      - apt-get install -y postgresql-client-10
      - git clone --recurse-submodules https://gitlab.c3sl.ufpr.br/simmctic/form-creator/form-creator-database.git form-creator-database
      - cd  form-creator-database
      - psql-manager/manager.sh create workspace
      - psql-manager/manager.sh fixture workspace
      - cd ..
      - rm -rf form-creator-database
40 41 42 43 44 45 46
    script:
        - yarn install --frozen-lockfile --silent --non-interactive
        - ln -s config.env.example config/test.env
        - yarn test
        - yarn run lint
    tags:
        - node
47 48 49 50

build:
    stage: build
    script:
51 52
        - image_version=$(grep \"version\" ./package.json |  cut -f2 -d':'| sed -e 's/"\|,//g' | tr -d ' ')
        - docker build -t ${DOCKER_URL}:${image_version} -t ${DOCKER_URL}:latest .
53 54 55 56 57 58 59
    tags:
        - docker
        - build

deploy:
    stage: deploy
    script:
60 61 62
        - image_version=$(grep \"version\" ./package.json |  cut -f2 -d':'| sed -e 's/"\|,//g' | tr -d ' ')
        - docker push ${DOCKER_URL}:${image_version}
        - docker push ${DOCKER_URL}:latest
63 64 65 66 67
    tags:
        - docker
        - build
    only:
        - master