Feat/Singleton Token #54
Workflow file for this run
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
| # CD-Firebase.yml - Firebase App Distribution 배포 워크플로우 | |
| name: Firebase App Distribution CD | |
| # 워크플로우 트리거 설정 | |
| on: | |
| pull_request: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| jobs: | |
| firebase_distribution: | |
| name: Firebase App Distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 코드 체크아웃 | |
| uses: actions/checkout@v4 | |
| - name: JDK 17 설정 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - 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: local.properties 설정 (Android용) | |
| run: | | |
| echo "BASE_URL=${{ secrets.BASE_URL }}" >> local.properties | |
| - name: NetworkConfig.local.kt 설정 (iOS용) | |
| run: | | |
| mkdir -p core/network/src/iosMain/kotlin/com/nexters/emotia/network/ | |
| cat > core/network/src/iosMain/kotlin/com/nexters/emotia/network/NetworkConfig.local.kt << EOF | |
| package com.nexters.emotia.network | |
| internal object NetworkConfigLocal { | |
| const val BASE_URL = "${{ secrets.BASE_URL }}" | |
| } | |
| EOF | |
| - name: network_security_config.xml 설정 | |
| run: | | |
| BASE_DOMAIN=$(echo "${{ secrets.BASE_URL }}" | sed 's/:[0-9]*$//') | |
| cat > composeApp/src/main/res/xml/network_security_config.xml << EOF | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <network-security-config> | |
| <domain-config cleartextTrafficPermitted="true"> | |
| <domain includeSubdomains="true">$BASE_DOMAIN</domain> | |
| </domain-config> | |
| </network-security-config> | |
| EOF | |
| - name: google-services.json 설정 | |
| # Firebase 서비스에 필요한 google-services.json 파일을 Secrets에서 가져와 복원합니다. | |
| run: | | |
| echo "Setting up google-services.json..." | |
| echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > ./composeApp/google-services.json | |
| if [ -f ./composeApp/google-services.json ]; then | |
| echo "google-services.json successfully created at ./composeApp/google-services.json" | |
| else | |
| echo "Error: google-services.json not found at ./composeApp/google-services.json" | |
| exit 1 | |
| fi | |
| shell: bash | |
| env: | |
| GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} | |
| - name: gradlew 실행 권한 부여 | |
| # gradlew 스크립트에 실행 권한이 없으면 빌드가 실패할 수 있으므로 권한을 부여합니다. | |
| run: chmod +x ./gradlew | |
| - name: 디버그 APK 빌드 (Firebase App Distribution용) | |
| # Firebase App Distribution을 위해 디버그 APK를 빌드합니다 (자동 서명됨). | |
| run: ./gradlew assembleDebug | |
| - name: APK 파일 확인 및 경로 설정 | |
| # 빌드된 APK 파일을 찾아서 환경변수로 설정합니다. | |
| run: | | |
| echo "=== APK 파일 검색 ===" | |
| find composeApp/build -name "*.apk" -type f || echo "APK 파일을 찾을 수 없습니다" | |
| echo "" | |
| echo "=== 빌드 디렉토리 구조 확인 ===" | |
| ls -la composeApp/build/ || echo "build 디렉토리가 없습니다" | |
| echo "" | |
| if [ -d "composeApp/build/intermediates" ]; then | |
| echo "=== intermediates 디렉토리 ===" | |
| find composeApp/build/intermediates -name "*.apk" -type f || echo "intermediates에 APK 없음" | |
| fi | |
| echo "" | |
| if [ -d "composeApp/build/outputs" ]; then | |
| echo "=== outputs 디렉토리 ===" | |
| find composeApp/build/outputs -name "*.apk" -type f || echo "outputs에 APK 없음" | |
| fi | |
| echo "" | |
| echo "=== APK 경로 설정 ===" | |
| APK_FILE=$(find composeApp/build -name "*debug*.apk" -type f | head -1) | |
| if [ -n "$APK_FILE" ]; then | |
| echo "APK_PATH=$APK_FILE" >> $GITHUB_ENV | |
| echo "✅ APK 파일 발견: $APK_FILE" | |
| else | |
| echo "❌ APK 파일을 찾을 수 없습니다" | |
| exit 1 | |
| fi | |
| - name: Firebase App Distribution 업로드 | |
| # 빌드된 디버그 APK를 Firebase App Distribution으로 업로드합니다. | |
| uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
| with: | |
| appId: ${{ secrets.FIREBASE_APP_ID }} | |
| serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} | |
| groups: 'testers' | |
| file: ${{ env.APK_PATH }} | |
| - name: Slack 알림 (빌드 성공) | |
| if: success() | |
| uses: 8398a7/action-slack@v3 | |
| with: | |
| status: success | |
| fields: workflow,job,commit,repo,author,took,ref | |
| author_name: GitHub Actions | |
| text: "🚀 Firebase App Distribution 배포 성공! 브랜치: `${{ github.ref_name }}` 커밋: `${{ github.sha }}`" | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| - name: Slack 알림 (빌드 실패) | |
| if: failure() | |
| uses: 8398a7/action-slack@v3 | |
| with: | |
| status: failure | |
| fields: workflow,job,commit,repo,author,took,ref | |
| author_name: GitHub Actions | |
| text: "🚨 Firebase App Distribution 배포 실패! 브랜치: `${{ github.ref_name }}` 커밋: `${{ github.sha }}`" | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |