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:
      - dotnet restore "TP Blazor".sln
      - dotnet build "TP Blazor".sln -c Release --no-restore
      - dotnet publish "TP Blazor".sln -c Release --no-restore -o CI_PROJECT_DIR/build/release

  - 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 ]

    
  - name: docker-build
    image: plugins/docker
    settings:
      dockerfile: TP Blazor/Dockerfile
      context: .
      registry: hub.codefirst.iut.uca.fr
      repo: hub.codefirst.iut.uca.fr/victor_perez.ngounou/tp_blazor
      username:
        from_secret: SECRET_REGISTRY_USERNAME
      password:
        from_secret: SECRET_REGISTRY_PASSWORD
    when:
      branch:
        - master
    depends_on: [ build ]
    
  - name: deploy-container
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
      IMAGENAME: hub.codefirst.iut.uca.fr/victor_perez.ngounou/tp_blazor:latest
      CONTAINERNAME: tp_blazor
      COMMAND: create
      OVERWRITE: true
    depends_on: [ docker-build ]
    when:
      branch:
        - master
 

volumes:
  - name: docs
    temp: {}
    