React Native CodeBuild Setup
Add CICD Requirements to Repo
Update Codebuild Project
version: 0.2
env:
shell: bash
phases:
pre_build:
commands:
- export CODE_DIR=`pwd`
- export CONTAINER_DIR=/code
- current_requirements_checksum="$(md5sum package.json yarn.lock Dockerfile)"
- previous_requirements_checksum=$(cat /code/requirements_checksum.txt)
- echo "$current_requirements_checksum"
- echo "$previous_requirements_checksum"
- export ANDROID_HOME="$HOME/Android/Sdk"
- echo $SERVICE_ACCOUNT_CREDENTIALS_ENCODED | base64 -di >> $CODE_DIR/apps/crm-agent-mobile-app/android/app/service-account-credentials.json
- cp -r $CODE_DIR/. $CONTAINER_DIR
- |
if [[ "$current_requirements_checksum" = "$previous_requirements_checksum" ]];
then
echo "Checksum matched";
else
echo "Checksum didn't match";
exit -1;
fi
build:
commands:
- CI_BUILD_NUMBER=$CODEBUILD_BUILD_NUMBER
- cd $CONTAINER_DIR
- echo "NX_BACKEND_REST_URL=$NX_BACKEND_REST_URL" >> apps/crm-agent-mobile-app/.env
- echo "NX_BACKEND_GRAPHQL_URL=$NX_BACKEND_GRAPHQL_URL" >> apps/crm-agent-mobile-app/.env
- nohup npx nx run crm-agent-mobile-app:start-cicd:prod &
- cd apps/crm-agent-mobile-app/android
- sleep 15
# Build and Distribute the App
- ./gradlew assembleProdRelease appDistributionUploadProdRelease
- export APP_PATH_IN_S3=releases/$CODEBUILD_SOURCE_VERSION/app-prod-release.apk
- aws s3 cp $CODE_DIR/apps/crm-agent-mobile-app/android/app/build/outputs/apk/prod/release/app-prod-release.apk s3://$BUCKET_NAME/$APP_PATH_IN_S3
# Notify in iBCom with Apk URL
- python3 $CODE_DIR/mobile_app_post_build_script.py
- echo "Deployed $CI_BUILD_NUMBER"Setup Custom Base Image Build Project
Build the Base Image
Updating the Base Image
Last updated