include:
  template: Dependency-Scanning.gitlab-ci.yml

dependency_scanning:
  only:
    - schedules

test-frontend:
  image: node:lts-alpine
  stage: test
  before_script:
    - cd frontend
  stage: test
  script:
    - yarn install
    - yarn lint
  cache:
    paths:
      - frontend/node_modules/
      - frontend/.yarn
  only:
    changes:
      - frontend/*

test-backend:
  stage: test
  image: elixir:1.9
  variables:
    MIX_ENV: test
  only:
    changes:
      - backend/*
  before_script:
    - cd backend
  script:
    - mix local.hex --force
    - mix local.rebar --force
    - mix deps.get
    - mix deps.compile
    - mix credo --strict
    - mix sobelow --config
  cache:
    paths:
      - backend/deps/
      - backend/_build/

deploy-backend-production:
  stage: deploy
  environment:
    name: production
    url: https://phoenix.api.fediverse.space
  image: ilyasemenov/gitlab-ci-git-push
  only:
    - master
  except:
    - schedules
  script:
    - git-push dokku@api.fediverse.space:phoenix master

deploy-gephi-production:
  stage: deploy
  image: ilyasemenov/gitlab-ci-git-push
  environment:
    name: production
  only:
    - master
  except:
    - schedules
  script:
    - git-push dokku@api.fediverse.space:gephi master
