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
    image: plugins/docker
    settings:
       dockerfile: Sources/MovieFinder_API/Dockerfile
       context: Sources/
       registry: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
       repo: hub.codefirst.iut.uca.fr/lucas.delanier/moviefinder_api
       username:
         from_secret: SECRET_REGISTRY_USERNAME
       password:
         from_secret: SECRET_REGISTRY_PASSWORD
    # container deployment
  - name: deploy-container
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
        IMAGENAME: hub.codefirst.iut.uca.fr/lucas.delanier/moviefinder_api:latest
        CONTAINERNAME: containermoviefinder
        COMMAND: create
        OVERWRITE: true
volumes:
- name: docs
  temp: {}