Merge pull request #3720 from Rakshitha-D/debug_github_actions #44
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
| name: Android | |
| on: | |
| push: | |
| tags: | |
| - '*debug' | |
| jobs: | |
| build: | |
| environment: sunbird | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'zulu' | |
| cache: gradle | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v2 | |
| - name: Install specific platform and build tools | |
| run: | | |
| echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-35" | |
| echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;34.0.0" | |
| echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses | |
| - name: Check Android SDK versions | |
| run: | | |
| echo "ANDROID_HOME: $ANDROID_HOME" | |
| echo "Available Android platforms:" | |
| ls -la $ANDROID_SDK_ROOT/platforms/ | |
| echo "Available build tools:" | |
| ls -la $ANDROID_SDK_ROOT/build-tools/ | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: 22.x | |
| - name: Install Ionic | |
| run: npm install -g @ionic/cli | |
| - name: Install app dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Generate App Assets | |
| run: npx @capacitor/assets generate --iconBackgroundColor '#ffffff' --iconBackgroundColorDark '#222222' --splashBackgroundColor '#ffffff' --splashBackgroundColorDark '#111111' | |
| - name: Convert Windows line endings to Linux from the gradlew file | |
| run: sudo apt update && sudo apt install dos2unix && cd android && dos2unix ./gradlew && cd .. | |
| - name: Make ./gradlew command executable | |
| run: cd android && chmod +x ./gradlew && cd .. | |
| - name: Decode google-service | |
| id: decode_google-service | |
| uses: timheuer/[email protected] | |
| with: | |
| fileName: 'google-services.json' | |
| fileDir: '/home/runner/work/SunbirdEd-mobile-app/SunbirdEd-mobile-app/configurations/' | |
| encodedString: ${{ secrets.DEBUG_GOOGLE_SERVICE_CONTENT }} | |
| - name: Replace secrets in gradle.properties | |
| run: | | |
| sed -i 's|^base_url=.*|base_url=${{ vars.BASE_URL }}|' android/gradle.properties | |
| sed -i 's|^channel_id=.*|channel_id=${{ vars.CHANNEL_ID }}|' android/gradle.properties | |
| sed -i 's|^mobile_app_key=.*|mobile_app_key=${{ secrets.DEBUG_MOBILE_APP_KEY }}|' android/gradle.properties | |
| sed -i 's|^mobile_app_secret=.*|mobile_app_secret=${{ secrets.DEBUG_MOBILE_APP_SECRET }}|' android/gradle.properties | |
| - name: Decode Debug Keystore | |
| id: decode_debug_keystore | |
| uses: timheuer/[email protected] | |
| with: | |
| fileName: 'android_debug_keystore.jks' | |
| fileDir: '/home/runner/work/SunbirdEd-mobile-app/SunbirdEd-mobile-app/android/app/keystore/' | |
| encodedString: ${{ secrets.DEBUG_KEYSTORE }} | |
| - name: Create signing.properties from JSON secret | |
| run: | | |
| mkdir -p ${{ github.workspace }}/android/app/keystore | |
| trap 'rm -f signing.json' EXIT | |
| echo "${{ secrets.DEBUG_SIGNING_KEYS }}" | base64 --decode > signing.json | |
| DEBUG_SIGNING_STORE_PASSWORD=$(jq -r '.DEBUG_SIGNING_STORE_PASSWORD' signing.json) | |
| DEBUG_SIGNING_KEY_ALIAS=$(jq -r '.DEBUG_SIGNING_KEY_ALIAS' signing.json) | |
| DEBUG_SIGNING_KEY_PASSWORD=$(jq -r '.DEBUG_SIGNING_KEY_PASSWORD' signing.json) | |
| touch ${{ github.workspace }}/android/signing.properties | |
| echo "DEBUG_KEYSTORE=${{ github.workspace }}/android/app/keystore/android_debug_keystore.jks" >> ${{ github.workspace }}/android/signing.properties | |
| echo "DEBUG_SIGNING_STORE_PASSWORD=$DEBUG_SIGNING_STORE_PASSWORD" >> ${{ github.workspace }}/android/signing.properties | |
| echo "DEBUG_SIGNING_KEY_ALIAS=$DEBUG_SIGNING_KEY_ALIAS" >> ${{ github.workspace }}/android/signing.properties | |
| echo "DEBUG_SIGNING_KEY_PASSWORD=$DEBUG_SIGNING_KEY_PASSWORD" >> ${{ github.workspace }}/android/signing.properties | |
| - name: Build Ionic assets | |
| run: ionic build --prod | |
| - name: Capacitor Sync | |
| run: npx cap sync android | |
| - name: Copy and update android | |
| run: npx cap copy android && npx cap update android | |
| - name: Copy content-player files to Android assets | |
| run: | | |
| if [ ! -d "www/content-player" ]; then | |
| echo "Source directory www/content-player does not exist!" | |
| exit 1 | |
| fi | |
| mkdir -p android/app/src/main/assets/public/content-player | |
| cp -r www/content-player/* android/app/src/main/assets/public/content-player/ | |
| ls -R android/app/src/main/assets/public/content-player | |
| - name: Decode and export signing config | |
| id: signing | |
| run: | | |
| trap 'rm -f debug_signing.json' EXIT | |
| echo "${{ secrets.DEBUG_SIGNING_KEYS }}" | base64 --decode > debug_signing.json | |
| echo "DEBUG_SIGNING_KEY_ALIAS=$(jq -r '.DEBUG_SIGNING_KEY_ALIAS' debug_signing.json)" >> $GITHUB_ENV | |
| echo "DEBUG_SIGNING_KEY_PASSWORD=$(jq -r '.DEBUG_SIGNING_KEY_PASSWORD' debug_signing.json)" >> $GITHUB_ENV | |
| echo "DEBUG_SIGNING_STORE_PASSWORD=$(jq -r '.DEBUG_SIGNING_STORE_PASSWORD' debug_signing.json)" >> $GITHUB_ENV | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| rm -f debug_signing.json | |
| - name: Build debug APK | |
| run: cd android && ./gradlew assembleDebug -PenforceReleaseSigningForDebug=true | |
| - name: Upload Debug APK | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: debug-apk | |
| path: android/app/build/outputs/apk/debug/ | |
| - name: Set versionName to environment | |
| run: | | |
| VERSION_NAME=$(grep '^version_name=' android/gradle.properties | cut -d'=' -f2) | |
| echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | |
| - name: upload artifact to Firebase App Distribution | |
| uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
| with: | |
| appId: ${{secrets.FIREBASE_APP_ID}} | |
| serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} | |
| groups: sunbird-mobile-app | |
| file: android/app/build/outputs/apk/debug/sunbird-6.0.local-debug.apk | |
| releaseNotes: "v${{ env.VERSION_NAME }} tag-(${{ github.ref_name }}) (${{ github.run_number }})" |