kind: pipeline
type: docker
name: default

steps:
  - name: build
    image: node:20-alpine3.19
    commands:
      - npm install
      - npm run build

  - name: sonar
    image: sonarsource/sonar-scanner-cli:5
    commands:
      - sonar-scanner -Dsonar.projectKey="$PROJECT_KEY" -Dsonar.login="$SONAR_TOKEN" -Dsonar.host.url=https://codefirst.iut.uca.fr/sonar
    environment:
      PROJECT_KEY:
        from_secret: SONAR_PROJECT_KEY
      SONAR_TOKEN:
        from_secret: SONAR_TOKEN
    depends_on:
      - build
    when:
      branch:
        - master
        - ci/*
      event:
        - push
        - tag
