Skip to content

Commit dde8b5e

Browse files
authored
Merge pull request #242 from Team-Clody/feat/#226-gitaction-ci-cd
[FEAT/#226] Git Action CI/CD 워크플로우를 추가합니다.
2 parents a087607 + 321e5fd commit dde8b5e

File tree

5 files changed

+183
-0
lines changed

5 files changed

+183
-0
lines changed

.github/workflows/android_cd.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Clody CD
2+
3+
on:
4+
pull_request:
5+
branches: [ staging ]
6+
7+
jobs:
8+
cd:
9+
name: Continuous Deployment
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Checkout
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
# Gradle Cache
18+
- name: Cache Gradle dependencies
19+
uses: actions/cache@v4
20+
with:
21+
path: |
22+
~/.gradle/caches
23+
~/.gradle/wrapper
24+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
25+
restore-keys: |
26+
${{ runner.os }}-gradle-
27+
28+
# JDK
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: 17
33+
distribution: 'corretto'
34+
cache: gradle
35+
36+
# Android SDK
37+
- name: Setup Android SDK
38+
uses: android-actions/setup-android@v3
39+
40+
# gradlew 권한
41+
- name: Change gradlew permissions
42+
run: chmod +x gradlew
43+
44+
# google-services.json
45+
- name: Decode google-services.json
46+
env:
47+
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }}
48+
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json
49+
50+
# local.properties
51+
- name: Generate local.properties
52+
env:
53+
BASE_URL: ${{ secrets.BASE_URL }}
54+
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
55+
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
56+
GOOGLE_ADMOB_APP_ID: ${{ secrets.GOOGLE_ADMOB_APP_ID }}
57+
GOOGLE_ADMOB_UNIT_ID: ${{ secrets.GOOGLE_ADMOB_UNIT_ID }}
58+
run: |
59+
echo "baseUrl=$BASE_URL" >> local.properties
60+
echo "kakao.api.key=$KAKAO_API_KEY" >> local.properties
61+
echo "amplitude.api.key=$AMPLITUDE_API_KEY" >> local.properties
62+
echo "googleAdmob.app.id=$GOOGLE_ADMOB_APP_ID" >> local.properties
63+
echo "googleAdmob.unit.id=$GOOGLE_ADMOB_UNIT_ID" >> local.properties
64+
65+
# Release AAB 빌드
66+
- name: Build Release AAB
67+
run: ./gradlew bundleRelease --stacktrace
68+
69+
# Firebase 인증
70+
- name: Set up Firebase Service Account Credentials
71+
env:
72+
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}
73+
run: |
74+
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | base64 --decode > $HOME/firebase-credentials.json
75+
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json
76+
77+
# Firebase App Distribution
78+
- name: Upload AAB to Firebase App Distribution
79+
env:
80+
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
81+
run: |
82+
firebase appdistribution:distribute app/build/outputs/bundle/release/app-release.aab \
83+
--app "$FIREBASE_APP_ID" \
84+
--release-notes "🍀 새로운 테스트 버전이 업로드되었습니다!" \
85+
--groups "clody-tester-group"
86+
87+
# Discord Notification
88+
- name: Notify Discord
89+
env:
90+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
91+
run: |
92+
curl -H "Content-Type: application/json" \
93+
-X POST \
94+
-d '{"content": "🍀 새로운 테스트 버전이 업로드되었습니다!"}' \
95+
$DISCORD_WEBHOOK_URL

.github/workflows/android_ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Clody CI
2+
3+
# 언제 동작할지 설정
4+
on:
5+
pull_request:
6+
branches: [ develop ]
7+
paths:
8+
- 'app/**' # app 모듈 내부 변경
9+
- 'build.gradle' # 최상위 build.gradle
10+
- '**/*.kt' # 모든 Kotlin 파일 변경
11+
12+
# 공통 작업 디렉토리 설정
13+
defaults:
14+
run:
15+
working-directory: ./
16+
17+
# Job 정의
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest # Ubuntu 최신 이미지에서 실행
21+
22+
steps:
23+
# Gradle 캐싱 (속도 향상)
24+
- name: Cache Gradle packages
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.gradle/caches
29+
~/.gradle/wrapper
30+
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties', '**/*.gradle*', '**/gradle-wrapper.properties') }}
31+
restore-keys: |
32+
${{ runner.os }}-gradle-
33+
34+
# Android SDK 캐싱
35+
- name: Cache Android SDK
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.android
39+
key: ${{ runner.os }}-android
40+
41+
# GitHub Repo 코드 Checkout
42+
- name: Checkout the code
43+
uses: actions/checkout@v4
44+
45+
# JDK 17 설치 (Android 공식 권장 버전)
46+
- name: Setup JDK
47+
uses: actions/setup-java@v4
48+
with:
49+
distribution: 'corretto'
50+
java-version: '17'
51+
52+
# Android SDK 설치
53+
- name: Setup Android SDK
54+
uses: android-actions/setup-android@v3
55+
56+
# gradlew 실행 권한 부여
57+
- name: Grant execute permission for gradlew
58+
run: chmod +x gradlew
59+
60+
# Firebase google-services.json 복호화 및 설정
61+
- name: Decode google-services.json
62+
env:
63+
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} # base64로 암호화된 json 사용
64+
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json
65+
66+
# local.properties 생성
67+
- name: Generate local.properties
68+
env:
69+
BASE_URL: ${{ secrets.BASE_URL }}
70+
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
71+
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
72+
GOOGLE_ADMOB_APP_ID: ${{ secrets.GOOGLE_ADMOB_APP_ID }}
73+
GOOGLE_ADMOB_UNIT_ID: ${{ secrets.GOOGLE_ADMOB_UNIT_ID }}
74+
run: |
75+
echo "baseUrl=$BASE_URL" >> local.properties
76+
echo "kakao.api.key=$KAKAO_API_KEY" >> local.properties
77+
echo "amplitude.api.key=$AMPLITUDE_API_KEY" >> local.properties
78+
echo "googleAdmob.app.id=$GOOGLE_ADMOB_APP_ID" >> local.properties
79+
echo "googleAdmob.unit.id=$GOOGLE_ADMOB_UNIT_ID" >> local.properties
80+
81+
82+
# ------- Build & Lint -------
83+
- name: Run Lint and Build
84+
run: ./gradlew --no-daemon --configuration-cache ktlintCheck assembleDebug

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
alias(libs.plugins.kotlin.serialization)
1515
alias(libs.plugins.google.services)
1616
alias(libs.plugins.firebase.crashlytics.plugin)
17+
alias(libs.plugins.firebase.app.distribution)
1718
}
1819

1920
android {

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ plugins {
99
alias(libs.plugins.ktlint) apply false
1010
alias(libs.plugins.google.services) apply false
1111
alias(libs.plugins.firebase.crashlytics.plugin) apply false
12+
alias(libs.plugins.firebase.app.distribution) apply false
1213
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ firebase-messaging = "24.0.0"
3737
firebase-analytics = "22.2.0"
3838
firebase-crashlytics = "19.0.3"
3939
firebase-crashlytics-plugin = "3.0.2"
40+
firebase-app-distribution = "5.1.0"
4041

4142
amplitude = "1.+"
4243

@@ -121,6 +122,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
121122
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
122123
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
123124
firebase-crashlytics-plugin = { id = "com.google.firebase.crashlytics", version.ref = "firebase-crashlytics-plugin" }
125+
firebase-app-distribution = { id = "com.google.firebase.appdistribution", version.ref = "firebase-app-distribution" }
124126

125127
[bundles]
126128
androidx = [

0 commit comments

Comments
 (0)