diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml new file mode 100644 index 000000000..6924a59d6 --- /dev/null +++ b/.github/workflows/Staging.yml @@ -0,0 +1,141 @@ +name: Staging CI + +on: + pull_request: + branches: [ "surya-test" ] + + workflow_dispatch: + inputs: + run_unit_tests: + description: 'Run Unit Tests' + required: true + type: boolean + default: true + branch: + description: 'Branch to build' + required: true + default: 'develop' + publish_to_firebase: + description: 'Publish to Firebase App Distribution' + required: true + type: boolean + default: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Print Runner Info + run: | + echo "Runner Name: ${{ runner.name }}" + echo "Runner OS: ${{ runner.os }}" + echo "Runner Type: ${{ runner.arch }}" + + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch || github.ref }} + + - name: Checkout specific submodule + run: | + git submodule init apps/mobile-offline-downloader-android + git submodule update apps/mobile-offline-downloader-android + cd apps/mobile-offline-downloader-android + git checkout surya-test + + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Create google-services.json + env: + GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: | + pwd + echo $GOOGLE_SERVICES_JSON | base64 -di > open_source_data/student/google-services.json + + - name: Setup Code + run: sh ./open_source.sh + + - name: Create Secret.kt file + env: + SECRET_FILE: ${{ secrets.SECRET_FILE }} + run: | + mkdir -p app + echo $SECRET_FILE | base64 -di > apps/buildSrc/src/main/java/Secure.kt + + - name: Grant execute permission for gradlew + run: | + cd apps + chmod +x gradlew + + # - name: Run Unit Tests + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # run: | + # APP_SELECTION="${{ github.event.inputs.app_selection }}" + # EVENT_NAME="${{ github.event_name }}" + # mkdir -p output + # cd apps + # ./gradlew :student:testTwouDebugUnitTest + + # - name: Upload Unit Test Report + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # uses: actions/upload-artifact@v4 + # with: + # name: unit-test-report + # path: | + # app/build/test-results + # app/build/reports/tests + + # - name: Summarize Unit Test Results + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # run: | + # echo "### Unit Test Summary" >> $GITHUB_STEP_SUMMARY + # echo "" >> $GITHUB_STEP_SUMMARY + # echo "**Test Results:**" >> $GITHUB_STEP_SUMMARY + # grep -r "> $GITHUB_STEP_SUMMARY + + - name: Build Selected App(s) and zip apk output + run: | + EVENT_NAME="${{ github.event_name }}" + + cd apps + ./gradlew :student:assembleTwouDebug + + mkdir -p output + cp student/build/outputs/apk/twou/debug/student-twou-debug.apk output/ + zip -r app-staging-${{ github.run_number }}.zip output/ + + - name: Upload APK ZIP + uses: actions/upload-artifact@v4 + with: + name: app-staging-${{ github.run_number }} + path: apps/app-staging-${{ github.run_number }}.zip + + - name: Install Firebase CLI + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: npm install -g firebase-tools + + - name: Authenticate Firebase CLI + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: | + echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }}" | base64 -d > firebase-key.json + firebase login:ci --token "$(cat firebase-key.json)" + + - name: Publish to Firebase App Distribution + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: | + firebase appdistribution:distribute apps/output/student-twou-debug.apk \ + --app ${{ secrets.FIREBASE_APP_ID_DEGREES }} \ + --release-notes "Automated build from GitHub Actions" + + - name: Cleanup sensitive files and directories + run: | + echo "Cleaning up sensitive files..." + rm -rf apps diff --git a/.gitmodules b/.gitmodules index be7f7de0e..06b7c3fb6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "android-vault"] - path = android-vault - url = git@github.com:instructure/android-vault.git [submodule "apps/mobile-offline-downloader-android"] path = apps/mobile-offline-downloader-android - url = git@github.com:2uinc/mobile-offline-downloader-android.git + url = https://github.com/2uinc/mobile-offline-downloader-android.git