---
kind: pipeline
type: docker

platform:
  os: linux
  arch: amd64

steps:
  - name: api
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-api
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      username:
        from_secret: REGISTRY_USER
      password:
        from_secret: REGISTRY_PASS
      dockerfile: Containerfile
      context: .
    when:
      branch:
        - master
        - staging
      event:
        - push

  - name: frontend
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-frontend
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      username:
        from_secret: REGISTRY_USER
      password:
        from_secret: REGISTRY_PASS
      dockerfile: web/Containerfile
      context: web
    when:
      branch:
        - master
        - staging
      event:
        - push

  - name: validator
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-validator
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      username:
        from_secret: REGISTRY_USER
      password:
        from_secret: REGISTRY_PASS
      dockerfile: validation/Containerfile
      context: validation
    when:
      branch:
        - master
        - staging
      event:
        - push

  - name: deploy
    image: argoproj/argocd:latest
    commands:
      - argocd login --grpc-web cd.stricity.com --username $USERNAME --password $PASSWORD
      - argocd app --grpc-web set ${DRONE_BRANCH}-maps-service --kustomize-image registry.itzana.me/strafesnet/maptest-api:${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
      - argocd app --grpc-web set ${DRONE_BRANCH}-maps-service --kustomize-image registry.itzana.me/strafesnet/maptest-frontend:${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
      - argocd app --grpc-web set ${DRONE_BRANCH}-maps-service --kustomize-image registry.itzana.me/strafesnet/maptest-validator:${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
    environment:
      USERNAME:
        from_secret: ARGO_USER
      PASSWORD:
        from_secret: ARGO_PASS
    depends_on:
      - api
      - frontend
      - validator
    when:
      branch:
        - master
        - staging
      event:
        - push

# pr dry run
  - name: api-pr
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-validator
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      dockerfile: Containerfile
      context: .
      dry_run: true
    when:
      event:
        - pull_request

  - name: frontend-pr
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-validator
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      dockerfile: web/Containerfile
      context: web
      dry_run: true
    when:
      event:
      - pull_request

  - name: validator-pr
    image: plugins/docker
    settings:
      registry: registry.itzana.me
      repo: registry.itzana.me/strafesnet/maptest-validator
      tags:
        - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
        - ${DRONE_BRANCH}
      dockerfile: validation/Containerfile
      context: validation
      dry_run: true
    when:
      event:
        - pull_request

  - name: build-pr
    image: alpine
    commands:
      - echo "Success!"
    depends_on:
      - api-pr
      - frontend-pr
      - validator-pr
    when:
      event:
        - pull_request
---
kind: signature
hmac: 11e6d7f1eb839d3798fdcb642ca5523c011bd14c1f3a0343a9c3106bab9ef142

...