kind: pipeline
type: docker
name: default
 
trigger:
  event:
    - push

steps:
  - name: build
    image: mcr.microsoft.com/dotnet/sdk:6.0
    volumes:
      - name: docs
        path: /docs
    commands:
      - cd Sources/
      - dotnet restore Solution.sln
      - dotnet build Solution.sln -c Release --no-restore
      - dotnet publish Solution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release

  - name: tests
    image: mcr.microsoft.com/dotnet/sdk:6.0
    commands:
      - cd Sources/
      - dotnet restore Solution.sln
      - dotnet test Solution.sln --no-restore
    depends_on: [build]

  - name: generate-and-deploy-docs
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
    failure: ignore
    volumes:
      - name: docs
        path: /docs
    commands:
      - cd Documentation/doxygen
      - doxygen Doxyfile
      - /entrypoint.sh
    when:
      branch:
        - master
    depends_on: [build]
    
  # docker image build
  - name: docker-build-and-push-api-rest
    image: plugins/docker
    settings:
      dockerfile: Sources/DockerfileRestFull
      context: Sources
      registry: hub.codefirst.iut.uca.fr
      repo: hub.codefirst.iut.uca.fr/victor_perez.ngounou/bowling-api-rest
      username:
        from_secret: SECRET_REGISTRY_USERNAME
      password:
        from_secret: SECRET_REGISTRY_PASSWORD
      depends_on: [build]
     # when:
      #  branch:
       #   - master


  - name: docker-build-and-push-api-gateway
    image: plugins/docker
    settings:
      dockerfile: Sources/DockerfileGateway
      context: Sources
      registry: hub.codefirst.iut.uca.fr
      repo: hub.codefirst.iut.uca.fr/victor_perez.ngounou/bowling-api-gateway
      username:
        from_secret: SECRET_REGISTRY_USERNAME
      password:
        from_secret: SECRET_REGISTRY_PASSWORD
      depends_on: [build]
      #when:
       # branch:
        #  - master
        
   #container deployment
  - name: deploy-container-restfull
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
      IMAGENAME: hub.codefirst.iut.uca.fr/victor_perez.ngounou/bowling-api-rest:latest
      CONTAINERNAME: bowling-api-rest
      COMMAND: create
      OVERWRITE: truee
    depends_on: [docker-build-and-push-api-rest]
   # when:
    #    branch:
     #       - master
    
  - name: deploy-container-gateway
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
      IMAGENAME: hub.codefirst.iut.uca.fr/victor_perez.ngounou/bowling-api-gateway:latest
      CONTAINERNAME: bowling-api-gateway
      COMMAND: create
      OVERWRITE: truee
    depends_on: [docker-build-and-push-api-gateway]
    #when: 
     # branch:
      #  - master

volumes:
- name: docs
  temp: {}
  
  
