-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (86 loc) · 2.83 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: CI Pipeline
on:
push:
branches:
[ main ]
pull_request:
branches:
[ main ]
types:
[opened, synchronize, reopened]
jobs:
Continuous-Integration:
runs-on: ubuntu-latest
#Action 환경에서 Redis 실행을 위한 설정 추후 서버 배포시 제거 예정
services:
redis:
image: redis
ports:
- 6379:6379
env:
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
REDIS_HOST: ${{ secrets.REDIS_HOST}}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }}
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }}
NAVER_SCOPE: ${{ secrets.NAVER_SCOPE }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- name: Github Repository 파일 불러오기
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: JDK 21 버전 설치
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Gradle 캐싱
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: SonarCloud 패키지 캐싱
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: 빌드 권한 부여
run: chmod +x ./gradlew
shell: bash
- name: 빌드 및 테스트
run: ./gradlew build
- name: Close PR, if build fail
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{ github.TOKEN }}
script: |
const pull_number = ${{ github.event.pull_request.number }}
const updated_title = `[BUILD FAIL] ${{ github.event.pull_request.title }}`
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
body: '빌드에 실패했습니다.',
event: 'REQUEST_CHANGES'
})
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
title: updated_title,
state: 'closed'
})
- name: SonarCloud 빌드및 분석
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info