From a384e129c6e7fd39367b154bbca4981eb3bef67f Mon Sep 17 00:00:00 2001 From: kingChan <281221230@qq.com> Date: Thu, 27 Jun 2024 14:26:42 +0800 Subject: [PATCH] update sonar insert_file --- app/controllers/api/v1/sonarqubes_controller.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/sonarqubes_controller.rb b/app/controllers/api/v1/sonarqubes_controller.rb index f7ec2a39c..29cfdd152 100644 --- a/app/controllers/api/v1/sonarqubes_controller.rb +++ b/app/controllers/api/v1/sonarqubes_controller.rb @@ -15,9 +15,19 @@ class Api::V1::SonarqubesController < Api::V1::BaseController end def insert_file + checkout_url = 'https://gitlink.org.cn/KingChan/checkout@v4' + scanner_url = 'https://gitlink.org.cn/KingChan/sonarqube-scan-action@master' begin config = Rails.application.config_for(:configuration) sonarqube_config = config.dig('sonarqube') + + if sonarqube_config.present? && sonarqube_config['checkout'].present? + checkout_url = sonarqube_config['checkout'] + end + if sonarqube_config.present? && sonarqube_config['scanner'].present? + scanner_url = sonarqube_config['scanner'] + end + raise 'sonar config missing' if sonarqube_config.blank? rescue => ex raise ex if Rails.env.production? @@ -47,12 +57,12 @@ class Api::V1::SonarqubesController < Api::V1::BaseController sonarqube: runs-on: ubuntu-latest steps: - - uses: #{sonarqube_config['checkout']} + - uses: #{checkout_url} with: # Disabling shallow clones is recommended for improving the relevancy of reporting fetch-depth: 0 - name: SonarQube Scan - uses: #{sonarqube_config['scanner']} + uses: #{scanner_url} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}