image: docker:stable
services:
    - docker:dind

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

stages:
  - test
  - publish


before_script:
    - apk --no-cache add python3 git

test:
    stage: test
    script:
        - git --no-pager diff --name-only origin/master
        - python3 publish_images.py -t
    tags:
        - docker
    except:
        - master

publish:
    stage: publish
    script:
        - git diff-tree --no-commit-id --name-only -r HEAD
        - python3 publish_images.py
    tags:
        - docker
    only:
        - master
