Support for firebase app distribution #2
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: Build APK | |
| permissions: | |
| contents: read | |
| actions: write | |
| on: | |
| pull_request: | |
| branches: [ "stage", "feature/**" ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'fastlane/**' | |
| - '.github/workflows/crowdin_contributors.yml' | |
| workflow_dispatch: { } | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Signing info (if needed) | |
| IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} | |
| IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} | |
| IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} | |
| IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} | |
| IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} | |
| IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} | |
| IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} | |
| # Publishing credentials (if needed) | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} | |
| # Build configuration | |
| BUILD_JAVA_VERSION: '17' | |
| BUILD_JAVA_DIST: 'temurin' | |
| jobs: | |
| build_apk: | |
| name: Build Universal APK | |
| runs-on: macos-13 | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Cancel previous runs | |
| uses: styfle/cancel-workflow-action@0.12.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update lib_source from Google Drive | |
| run: | | |
| echo "Removing existing lib_source folder..." | |
| rm -rf lib_source | |
| echo "Installing gdown..." | |
| pip install gdown | |
| echo "Downloading lib_source zip from Google Drive..." | |
| # Replace <ZIP_FILE_ID> with the actual file ID of your zip archive. | |
| gdown --fuzzy "https://drive.google.com/uc?id=1O-oOP5_t3QlvnXGOC03w1SYakxrUi4Xk&confirm=t" -O lib_source.zip | |
| echo "Unzipping lib_source.zip..." | |
| unzip lib_source.zip -d lib_source | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ env.BUILD_JAVA_VERSION }} | |
| distribution: ${{ env.BUILD_JAVA_DIST }} | |
| - name: Initialize submodules | |
| run: | | |
| git submodule init | |
| git submodule update --remote | |
| - name: Install CMake | |
| run: | | |
| brew update | |
| brew install cmake | |
| - name: Restore Gradle Cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Assemble Universal APK | |
| run: ./gradlew assembleDebug | |
| - name: Extract branch folder name | |
| id: extract_branch | |
| run: | | |
| # Remove "refs/heads/" and split by "/" to get the folder name (e.g. "ADFA-123") | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| FOLDER_NAME=${BRANCH_NAME#*/} | |
| echo "Branch: $BRANCH_NAME" | |
| echo "Folder Name: $FOLDER_NAME" | |
| echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV | |
| - name: Download Firebase Service Account JSON using curl | |
| id: download_service_account | |
| run: | | |
| curl -L "https://jsonblob.com/api/jsonBlob/1354004779097055232" -o firebase-service-account.json | |
| json=$(tr -d '\n' < firebase-service-account.json) | |
| echo "json=$json" >> $GITHUB_OUTPUT | |
| - name: Upload APK to Firebase App Distribution | |
| uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
| with: | |
| appId: codeonthego-64a92 | |
| serviceCredentialsFileContent: ${{ steps.download_service_account.outputs.json }} | |
| groups: testers | |
| file: app/build/outputs/apk/debug/CodeOnTheGo-*.apk | |
| releaseNotes: "Commit Message: ${{ env.COMMIT_MESSAGE }}" | |
| - name: Slack Notification | |
| run: | | |
| # Compose a Slack message with emojis and the download URL | |
| MESSAGE=":tada: *Build Completed! And deployed to firebase!* :rocket:Jira Ticket: https://appdevforall.atlassian.net/browse/${FOLDER_NAME}" | |
| curl -X POST -H 'Content-type: application/json' \ | |
| --data "{\"text\": \"${MESSAGE}\"}" \ | |
| https://hooks.slack.com/services/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 |