name: 'Java CI Build'
description: 'Build a Java CI project with maven and Docker'
inputs:
   GITHUBLOGIN:
    description: 'A Github login'
    required: true
   GITHUBPASSWORD:
    description: 'A Github PAT'
    required: true
   DOCKER_USERNAME:
    description: 'A Docker username'
    required: true
   DOCKER_PASSWORD:
    description: 'A Docker token'
    required: true
   SONAR_URL:
    description: 'A sonar URL'
    required: true
   SONAR_TOKEN:
    description: 'A sonar token'
    required: true

runs:
  using: "composite"
  steps:
      # build the project in a docker container with a specific maven settings.xml
      # it uses env variables from github secrets for the credentials
      # to github, dockerhub and sonar.
      - name: Build and test with Maven in docker
        run: ./mvn.sh clean verify
        shell: bash
      - name: Deploy Maven Artifacts
        run: ./mvn.sh deploy
        shell: bash
      - name: Notify dedicated teams channel of Success
        uses: dragos-cojocari/ms-teams-notification@v1.0.0
        if: ${{ success() }}
        with:
          github-token: ${{ github.token }} # this will use the runner's token.
          ms-teams-webhook-uri: ${{ input.MSTEAMS_WEBHOOK }}
          notification-summary: Build and Deploy success.
          notification-color: 28a745
          timezone: Europe/Paris
      - name: Notify dedicated teams channel of Failure
        uses: dragos-cojocari/ms-teams-notification@v1.0.0
        if: ${{ failure() }}
        with:
          github-token: ${{ github.token }} # this will use the runner's token.
          ms-teams-webhook-uri: ${{ input.MSTEAMS_WEBHOOK }}
          notification-summary: Build and Deploy failure.
          notification-color: dc3545
          timezone: Europe/Paris