[TEST] 테스트 앱 배포를 진행합니다. #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| # Install Firebase CLI | |
| - name: Install Firebase CLI | |
| run: curl -sL https://firebase.tools | bash | |
| # 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 APK 빌드 | |
| - name: Build Release APK | |
| run: ./gradlew assembleRelease --stacktrace | |
| # Set up Firebase Service Account Credentials | |
| - 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 | |
| echo "🔥 Firebase Credentials JSON 생성 완료!" | |
| ls -l $HOME/firebase-credentials.json | |
| export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
| echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" | |
| # Firebase CLI 인증 확인 | |
| - name: Check Firebase CLI Authentication | |
| run: | | |
| export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
| echo "📌 GOOGLE_APPLICATION_CREDENTIALS 설정 값:" | |
| echo $GOOGLE_APPLICATION_CREDENTIALS | |
| ls -l $GOOGLE_APPLICATION_CREDENTIALS | |
| echo "📌 현재 Firebase 프로젝트 목록 확인:" | |
| firebase projects:list || (echo "❌ Firebase 인증 실패!"; exit 1) | |
| # Firebase App Distribution Upload | |
| - name: Upload APK to Firebase App Distribution | |
| env: | |
| GOOGLE_APPLICATION_CREDENTIALS: $HOME/firebase-credentials.json | |
| FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} | |
| run: | | |
| echo "🔥 FIREBASE_APP_ID 확인: $FIREBASE_APP_ID" | |
| # 만약 FIREBASE_APP_ID가 없으면 에러 출력 후 종료 | |
| if [ -z "$FIREBASE_APP_ID" ]; then | |
| echo "❌ ERROR: FIREBASE_APP_ID가 설정되지 않았습니다. GitHub Secrets에서 확인하세요." | |
| exit 1 | |
| fi | |
| # GOOGLE_APPLICATION_CREDENTIALS 재 설정 | |
| export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
| echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" | |
| firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \ | |
| --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 |