From 560a083d15c105803899cb5a4d1e2a5f8f3ceec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F-Lab=20=EC=BD=94=EB=93=9C=EB=A6=AC=EB=B7=B0=20=EB=B4=87?= <155365540+f-lab-bot@users.noreply.github.com> Date: Wed, 3 Jan 2024 18:45:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=20PR=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20workflow=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20by=20f-lab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonarcloud-analyze.yml | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/sonarcloud-analyze.yml diff --git a/.github/workflows/sonarcloud-analyze.yml b/.github/workflows/sonarcloud-analyze.yml new file mode 100644 index 0000000..237e0a9 --- /dev/null +++ b/.github/workflows/sonarcloud-analyze.yml @@ -0,0 +1,49 @@ +name: F-Lab SonarCloud Code Analyze + +on: + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +env: + CACHED_DEPENDENCIES_PATHS: '**/node_modules' + +jobs: + CodeAnalyze: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set SonarCloud Project Key + run: | + REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2) + ORG_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1) + SONAR_PROJECT_KEY="${ORG_NAME}_${REPO_NAME}" + echo "SONAR_PROJECT_KEY=$SONAR_PROJECT_KEY" >> $GITHUB_ENV + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '19' + distribution: 'adopt' + + - name: Create Sonar Gradle File + run: | + insert_string="plugins { id 'org.sonarqube' version '4.4.1.3373' }" + if [ -f "build.gradle" ]; then + echo "$insert_string" > temp.gradle + cat build.gradle >> temp.gradle + mv temp.gradle build.gradle + else + echo "$insert_string" > build.gradle + fi + + - name: Analyze + run: ./gradlew sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.organization=f-lab-edu-1 -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=${{ secrets.SECRET_SONARQUBE }} -Dsonar.gradle.skipCompile=true + env: + SONAR_TOKEN: ${{ secrets.SECRET_SONARQUBE }} + + \ No newline at end of file