Orbit CD #74
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: | |
| - 'release/**' | |
| pull_request: | |
| branches: | |
| - 'release/**' | |
| workflow_dispatch: | |
| jobs: | |
| cd: | |
| name: Continuous Deployment | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. Cache Gradle | |
| - 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. Set up JDK 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: 'corretto' | |
| cache: gradle | |
| # 4. Change gradlew permissions | |
| - name: Change gradlew permissions | |
| run: chmod +x gradlew | |
| # 5. Decode google-services.json (release) | |
| - name: Decode google-services.json (release) | |
| env: | |
| FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET_RELEASE }} | |
| run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json | |
| # 6. Add Local Properties | |
| - name: Add Local Properties | |
| env: | |
| BASE_URL: ${{ secrets.BASE_URL }} | |
| AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }} | |
| ADMOB_APP_ID_RELEASE: ${{ secrets.ADMOB_APP_ID_RELEASE }} | |
| ADMOB_AD_UNIT_ID_RELEASE: ${{ secrets.ADMOB_AD_UNIT_ID_RELEASE }} | |
| run: | | |
| echo "baseUrl=$BASE_URL" > local.properties | |
| echo "amplitudeApiKey=$AMPLITUDE_API_KEY" >> local.properties | |
| echo "admobAppIdRelease=$ADMOB_APP_ID_RELEASE" >> local.properties | |
| echo "admobAdUnitIdRelease=$ADMOB_AD_UNIT_ID_RELEASE" >> local.properties | |
| # 7. Build Release APK | |
| - name: Build Release APK | |
| run: ./gradlew assembleRelease --stacktrace | |
| # 8. Upload Release APK | |
| - name: Upload Release APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-apk | |
| path: app/build/outputs/apk/release/app-release.apk | |
| # 9. Set up Firebase Credentials | |
| - name: Set up Firebase Credentials | |
| env: | |
| GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} | |
| run: | | |
| echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | base64 --decode > $HOME/firebase-credentials.json | |
| echo "GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json" >> $GITHUB_ENV | |
| # 10. Install Firebase CLI | |
| - name: Install Firebase CLI | |
| run: curl -sL https://firebase.tools | bash | |
| # 11. Upload to Firebase App Distribution | |
| - name: Upload APK to Firebase App Distribution | |
| env: | |
| GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }} | |
| FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} | |
| run: | | |
| if [ -z "$FIREBASE_APP_ID" ]; then | |
| echo "β ERROR: FIREBASE_APP_ID is missing!" | |
| exit 1 | |
| fi | |
| firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \ | |
| --app "$FIREBASE_APP_ID" \ | |
| --release-notes "π release λΈλμΉμμ μ λΉλκ° μ λ‘λλμμ΅λλ€!" \ | |
| --groups "orbit-tester-group" | |
| # 12. 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μ μ APKκ° μ λ‘λλμμ΅λλ€!\nπ λ€μ΄λ‘λ λ§ν¬: https://appdistribution.firebase.google.com"}' \ | |
| $DISCORD_WEBHOOK_URL |