From 80b96221aa9f3aa45f19ce2593659a76438f1321 Mon Sep 17 00:00:00 2001
From: Bornyto Hamonangan <bornyto.hamonangan@ui.ac.id>
Date: Mon, 13 Mar 2023 20:35:42 +0700
Subject: [PATCH] Update .gitlab-ci.yml file

---
 .gitlab-ci.yml | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 51b93b0..55f7d91 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ stages:
 - sonarqube
 - heroku_deploy
 
-sonarqube-check:
+sonarqube-check-staging:
   stage: sonarqube
   image: 
     name: sonarsource/sonar-scanner-cli:latest
@@ -15,15 +15,32 @@ sonarqube-check:
     paths:
       - .sonar/cache
   script: 
-    - sonar-scanner -D"sonar.projectKey=ppi-staging" -D"sonar.sources=." -D"sonar.host.url=https://sonarqube.cs.ui.ac.id" -D"sonar.login=a4b8d517cfba77c391a010305d56e394d4e520a9"
+    - sonar-scanner -D"sonar.projectKey=${SONAR_PROJECT_KEY_STAGING}" -D"sonar.sources=." -D"sonar.host.url=https://sonarqube.cs.ui.ac.id" -D"sonar.login=${SONAR_TOKEN_STAGING}"
   
   allow_failure: true
 
   only:
-    - main 
     - staging
 
+sonarqube-check-prod:
+  stage: sonarqube
+  image: 
+    name: sonarsource/sonar-scanner-cli:latest
+    entrypoint: [ "" ]
+  variables:
+    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
+    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
+  cache:
+    key: "${CI_JOB_NAME}"
+    paths:
+      - .sonar/cache
+  script: 
+    - sonar-scanner -D"sonar.projectKey=${SONAR_PROJECT_KEY_PROD}" -D"sonar.sources=." -D"sonar.host.url=https://sonarqube.cs.ui.ac.id" -D"sonar.login=${SONAR_TOKEN_PROD}"
+  
+  allow_failure: true
 
+  only:
+    - main
 
 heroku_deploy:
   stage: heroku_deploy
-- 
GitLab