You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LeftOvers_Api/.drone.yml

143 lines
3.8 KiB

kind: pipeline
type: docker
name: CI
trigger:
event:
- push
steps:
- name: api-build
image: node:latest
environment:
DB_USERNAME:
from_secret: SECRET_DB_USERNAME
DB_DBHOST:
from_secret: SECRET_DB_DBHOST
DB_DBNAME:
from_secret: SECRET_DB_DBNAME
DB_USERPASSWORD:
from_secret: SECRET_DB_USERPASSWORD
DB_PORT:
from_secret: SECRET_DB_PORT
commands:
- cd ./API-Project
- npm install
- npm run build
- name: publish-jest-reports
image: node:latest
environment:
DB_USERNAME:
from_secret: SECRET_DB_USERNAME
DB_DBHOST:
from_secret: SECRET_DB_DBHOST
DB_DBNAME:
from_secret: SECRET_DB_DBNAME
DB_USERPASSWORD:
from_secret: SECRET_DB_USERPASSWORD
DB_PORT:
from_secret: SECRET_DB_PORT
commands:
- cd ./API-Project
- npm run test:coverage
depends_on: [ api-build ]
- name: code-analysis
image: node:latest
environment:
SONAR_TOKEN:
from_secret: SONAR_TOKEN
settings:
sources: ./API-Project/src
tests: ./API-Project/tests
sonar.testExecutionReportPaths: ./API-Project/coverage/sonar-report.xml
javascript.lcov.reportPaths: ./API-Project/coverage/lcov.info
commands:
- export SONAR_SCANNER_VERSION=4.7.0.2747
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -X -D sonar.projectKey=LeftOvers_Api -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
depends_on: [ api-build ]
---
kind: pipeline
type: docker
name: CD
trigger:
branch:
- master
event:
- push
steps:
- name: api-build
image: node:latest
environment:
DB_USERNAME:
from_secret: SECRET_DB_USERNAME
DB_DBHOST:
from_secret: SECRET_DB_DBHOST
DB_DBNAME:
from_secret: SECRET_DB_DBNAME
DB_USERPASSWORD:
from_secret: SECRET_DB_USERPASSWORD
DB_PORT:
from_secret: SECRET_DB_PORT
commands:
- cd ./API-Project
- npm install
- npm run build
- name: docker-build-and-push
image: plugins/docker
environment:
DB_USERNAME:
from_secret: SECRET_DB_USERNAME
DB_DBHOST:
from_secret: SECRET_DB_DBHOST
DB_DBNAME:
from_secret: SECRET_DB_DBNAME
DB_USERPASSWORD:
from_secret: SECRET_DB_USERPASSWORD
DB_PORT:
from_secret: SECRET_DB_PORT
settings:
dockerfile: API-Project/Dockerfile
context: API-Project
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/rayhan.hassou/leftovers_api
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
depends_on: [ api-build ]
#container deployment
- name: deploy-container
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/rayhan.hassou/leftovers_api:latest
CONTAINERNAME: left-over-container
COMMAND: create
OVERWRITE: true
ADMINS: louison.parant,remi.regnault,rayhan.hassou
DB_USERNAME:
from_secret: SECRET_DB_USERNAME
DB_DBHOST:
from_secret: SECRET_DB_DBHOST
DB_DBNAME:
from_secret: SECRET_DB_DBNAME
DB_USERPASSWORD:
from_secret: SECRET_DB_USERPASSWORD
DB_PORT:
from_secret: SECRET_DB_PORT
depends_on: [ docker-build-and-push ]