 include:
   local: 'docker.gitlab-ci.yml'

 variables:
   DOCKER_HOST: tcp://localhost:2375
   DOCKER_DRIVER: overlay2

 stages:
   - version
   - build
   - deploy

 versioning:
   stage: version
   image: docker:19.03.4
   artifacts:
     paths:
       - shared-vars.sh
     expire_in: 1 day
   script:
     - echo "export VERSION=$(cat sga-daemon-*.rockspec | grep 'version[[:space:]]=[[:space:]]' | awk '{print $3}' | sed -e s/[\",]//g)" >> shared-vars.sh
   only:
     - master
     - tags

 static_check:
   stage: build
   image: repo.tecgraf.puc-rio.br:18089/soma/ubuntu:16.04-sga-posix
   script:
     - mkdir sgarest-daemon
     - curl -L https://git.tecgraf.puc-rio.br/csbase-dev/sgarest-daemon/-/archive/master/sgarest-daemon-master.tar.gz | tar xzf - -C sgarest-daemon --strip-components 1
     - cd sgarest-daemon
     - export errors=$(luac5.3 -p sgad | find . -regex ".*\.lua"  | awk '{print "luac5.3 -p "$1}' | sh -) 
     - ([ -z "$errors" ] && exit 0 || exit 1)
   only:
     - master
     - tags
