Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SonarCloud Code Analyze Workflow 등록 #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/sonarcloud-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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
echo "" >> temp.gradle
echo "sonarqube {" >> temp.gradle
echo " properties {" >> temp.gradle
echo " property 'sonar.java.binaries', '**'" >> temp.gradle
echo " }" >> temp.gradle
echo "}" >> temp.gradle
mv temp.gradle build.gradle
else
echo "$insert_string" > build.gradle
echo "" >> build.gradle
echo "sonarqube {" >> build.gradle
echo " properties {" >> build.gradle
echo " property 'sonar.java.binaries', '**'" >> build.gradle
echo " }" >> build.gradle
echo "}" >> build.gradle
fi
chmod 777 ./gradlew


- 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 }}


Loading