Skip to content
Merged
Show file tree
Hide file tree
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
95 changes: 95 additions & 0 deletions .github/workflows/android_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Clody CD

on:
pull_request:
branches: [ staging ]

jobs:
cd:
name: Continuous Deployment
runs-on: ubuntu-latest

steps:
# Checkout
- name: Checkout code
uses: actions/checkout@v4

# Gradle Cache
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

# JDK
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'corretto'
cache: gradle

# Android SDK
- name: Setup Android SDK
uses: android-actions/setup-android@v3

# gradlew 권한
- name: Change gradlew permissions
run: chmod +x gradlew

# google-services.json
- name: Decode google-services.json
env:
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }}
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json

# local.properties
- name: Generate local.properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
GOOGLE_ADMOB_APP_ID: ${{ secrets.GOOGLE_ADMOB_APP_ID }}
GOOGLE_ADMOB_UNIT_ID: ${{ secrets.GOOGLE_ADMOB_UNIT_ID }}
run: |
echo "baseUrl=$BASE_URL" >> local.properties
echo "kakao.api.key=$KAKAO_API_KEY" >> local.properties
echo "amplitude.api.key=$AMPLITUDE_API_KEY" >> local.properties
echo "googleAdmob.app.id=$GOOGLE_ADMOB_APP_ID" >> local.properties
echo "googleAdmob.unit.id=$GOOGLE_ADMOB_UNIT_ID" >> local.properties

# Release AAB 빌드
- name: Build Release AAB
run: ./gradlew bundleRelease --stacktrace

# Firebase 인증
- name: Set up Firebase Service Account Credentials
env:
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}
run: |
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | base64 --decode > $HOME/firebase-credentials.json
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json

Comment on lines +69 to +76
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Firebase Service Account Credentials Setup

The steps on lines 69–76 decode the Firebase service account credentials and set the GOOGLE_APPLICATION_CREDENTIALS environment variable.

Note: Consider adding an explicit step to install the Firebase CLI (for example, using npm install -g firebase-tools) if it is not pre-installed on the ubuntu-latest image. This ensures that the subsequent Firebase distribution command will execute reliably.

# Firebase App Distribution
- name: Upload AAB to Firebase App Distribution
env:
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
run: |
firebase appdistribution:distribute app/build/outputs/bundle/release/app-release.aab \
--app "$FIREBASE_APP_ID" \
--release-notes "🍀 새로운 테스트 버전이 업로드되었습니다!" \
--groups "clody-tester-group"

# Discord Notification
- name: Notify Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{"content": "🍀 새로운 테스트 버전이 업로드되었습니다!"}' \
$DISCORD_WEBHOOK_URL
84 changes: 84 additions & 0 deletions .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Clody CI

# 언제 동작할지 설정
on:
pull_request:
branches: [ develop ]
paths:
- 'app/**' # app 모듈 내부 변경
- 'build.gradle' # 최상위 build.gradle
- '**/*.kt' # 모든 Kotlin 파일 변경

# 공통 작업 디렉토리 설정
defaults:
run:
working-directory: ./

# Job 정의
jobs:
build:
runs-on: ubuntu-latest # Ubuntu 최신 이미지에서 실행

steps:
# Gradle 캐싱 (속도 향상)
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties', '**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

# Android SDK 캐싱
- name: Cache Android SDK
uses: actions/cache@v4
with:
path: ~/.android
key: ${{ runner.os }}-android

# GitHub Repo 코드 Checkout
- name: Checkout the code
uses: actions/checkout@v4

# JDK 17 설치 (Android 공식 권장 버전)
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'

# Android SDK 설치
- name: Setup Android SDK
uses: android-actions/setup-android@v3

# gradlew 실행 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Firebase google-services.json 복호화 및 설정
- name: Decode google-services.json
env:
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} # base64로 암호화된 json 사용
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json

# local.properties 생성
- name: Generate local.properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
GOOGLE_ADMOB_APP_ID: ${{ secrets.GOOGLE_ADMOB_APP_ID }}
GOOGLE_ADMOB_UNIT_ID: ${{ secrets.GOOGLE_ADMOB_UNIT_ID }}
run: |
echo "baseUrl=$BASE_URL" >> local.properties
echo "kakao.api.key=$KAKAO_API_KEY" >> local.properties
echo "amplitude.api.key=$AMPLITUDE_API_KEY" >> local.properties
echo "googleAdmob.app.id=$GOOGLE_ADMOB_APP_ID" >> local.properties
echo "googleAdmob.unit.id=$GOOGLE_ADMOB_UNIT_ID" >> local.properties


# ------- Build & Lint -------
- name: Run Lint and Build
run: ./gradlew --no-daemon --configuration-cache ktlintCheck assembleDebug
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.google.services)
alias(libs.plugins.firebase.crashlytics.plugin)
alias(libs.plugins.firebase.app.distribution)
}

android {
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ plugins {
alias(libs.plugins.ktlint) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.firebase.crashlytics.plugin) apply false
alias(libs.plugins.firebase.app.distribution) apply false
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ firebase-messaging = "24.0.0"
firebase-analytics = "22.2.0"
firebase-crashlytics = "19.0.3"
firebase-crashlytics-plugin = "3.0.2"
firebase-app-distribution = "5.1.0"

amplitude = "1.+"

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

[bundles]
androidx = [
Expand Down