Merge pull request #58 from YAPP-Github/develop #14
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: Orbit CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| cd: | |
| name: Continuous Deployment | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Code Checkout | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. 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- | |
| # 3. JDK 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: 'corretto' | |
| cache: gradle | |
| # 4. Grant Execute Permission | |
| - name: Change gradlew permissions | |
| run: chmod +x gradlew | |
| # 5. Install Firebase CLI | |
| - name: Install Firebase CLI | |
| run: curl -sL https://firebase.tools | bash | |
| # 6. Decode google-services.json | |
| - name: Decode google-services.json | |
| env: | |
| FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} | |
| run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json | |
| # 7. local.properties | |
| - name: Add local.properties | |
| env: | |
| BASE_URL: ${{ secrets.BASE_URL }} | |
| run: | | |
| echo "base.url=\"$BASE_URL\"" >> app/local.properties | |
| # 8. Ktlint | |
| - name: Run Ktlint Check | |
| run: ./gradlew ktlintCheck --stacktrace | |
| # 9. Debug APK Build | |
| - name: Build Debug APK | |
| run: ./gradlew assembleDebug --stacktrace | |
| # 10. Release AAB Build | |
| - name: Build Release AAB | |
| run: ./gradlew bundleRelease --stacktrace | |
| # 11. Release APK Build | |
| - name: Build Release APK | |
| run: ./gradlew assembleRelease --stacktrace | |
| # 12. AAB Artifact Upload | |
| - name: Upload Release AAB | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-aab | |
| path: app/build/outputs/bundle/release/app-release.aab | |
| # 13. APK Artifact Upload | |
| - name: Upload Release APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-apk | |
| path: app/build/outputs/apk/release/app-release.apk | |
| # 14. 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" | |
| # 15. 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) | |
| # 16. 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 "orbit-tester-group" | |
| # 17. Notify Discord | |
| - name: Notify Discord | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| run: | | |
| curl -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d '{"content": "π μλ‘μ΄ λ°λͺ¨ λ²μ μ΄ Firebase App Distributionμ μ λ‘λλμμ΅λλ€!\nAPK λ€μ΄λ‘λ: https://appdistribution.firebase.google.com"}' \ | |
| $DISCORD_WEBHOOK_URL |