#########################
# MANAGED BY MODULESYNC #
#########################

stages:
  - build
  - test
  - upload

variables:
  DOCKER_IMAGE_BASE: registry.icinga.com/build-docker

.build: &build
  stage: build
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
  script:
    - icinga-build-package
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - ccache/
      - 'icingaweb2-module-elasticsearch.git'
  artifacts:
    paths:
      - build/*
    expire_in: 1 week

.test: &test
  stage: test
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
  script:
    - find build/
    - icinga-build-test

.upload: &upload
  stage: upload
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/upload
  script:
    - find build/
    - icinga-build-upload-aptly
  only:
    - tags

###################################
# Debian
###################################

build/debian/buster:
  <<: *build
  variables:
    DOCKER_IMAGE: debian/buster

test/debian/buster:
  <<: *test
  variables:
    DOCKER_IMAGE: debian/buster
  dependencies:
    - build/debian/buster

upload/debian/buster:
  <<: *upload
  dependencies:
    - build/debian/buster

build/debian/stretch:
  <<: *build
  variables:
    DOCKER_IMAGE: debian/stretch

test/debian/stretch:
  <<: *test
  variables:
    DOCKER_IMAGE: debian/stretch
  dependencies:
    - build/debian/stretch

upload/debian/stretch:
  <<: *upload
  dependencies:
    - build/debian/stretch
###################################
# Ubuntu
###################################

build/ubuntu/disco:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/disco

test/ubuntu/disco:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/disco
  dependencies:
    - build/ubuntu/disco

upload/ubuntu/disco:
  <<: *upload
  dependencies:
    - build/ubuntu/disco

build/ubuntu/bionic:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/bionic

test/ubuntu/bionic:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/bionic
  dependencies:
    - build/ubuntu/bionic

upload/ubuntu/bionic:
  <<: *upload
  dependencies:
    - build/ubuntu/bionic

build/ubuntu/xenial:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/xenial

test/ubuntu/xenial:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/xenial
  dependencies:
    - build/ubuntu/xenial

upload/ubuntu/xenial:
  <<: *upload
  dependencies:
    - build/ubuntu/xenial
