Skip to content

Run code analyze triggered with pull request by BHyeonKim #5

Run code analyze triggered with pull request by BHyeonKim

Run code analyze triggered with pull request by BHyeonKim #5

Workflow file for this run

name: Code Analyze Pull Request
run-name: Run code analyze triggered with pull request by ${{github.actor}}
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
- dev
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build with tests
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
continue-on-error: true
run: ./gradlew build --info
- name: SonarQube Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: ./gradlew sonar --info
- name: Comment SonarQube URL on PR
uses: actions/github-script@v7
env:
SONAR_URL: ${{ secrets.SONAR_URL }}
PROJECT_KEY: "CleanEngine_cleanengine-be_2b6f2f63-fa39-426c-b9c7-8aa127fd14d8"
PR_NUMBER: ${{ github.event.pull_request.number }}
with:
script: |
const { SONAR_URL, PROJECT_KEY, PR_NUMBER } = process.env
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 소나큐브 코드 분석 결과 🔍
소나큐브 분석이 완료되었습니다. 아래 링크에서 결과를 확인하세요:
🔗 [소나큐브 분석 결과 보기](${SONAR_URL}/dashboard?id=${PROJECT_KEY})
테스트 결과에 관계없이 코드 품질 분석이 실행되었습니다.`
})