Skip to content

Build apk actions

Build apk actions #100

name: Build APK Workflow
on:
push:
branches: [ 'develop', 'master' ] # This specifies that the workflow will run on any push to the 'develop' or 'master' branches
pull_request:
branches: [ 'develop', 'master' ] # Optionally, run on pull requests targeting the 'develop' or 'master' branches
jobs:
build-apk:
runs-on: ubuntu-latest
environment: UAT
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin' # Specify the Java distribution
- name: Flutter action
uses: subosito/[email protected]
with:
flutter-version: "3.22.2"
- name: Set up Android SDK
uses: android-actions/setup-android@v2
with:
api-level: 33
build-tools: 33.0.2
- name: Install Dependencies
run: flutter pub get
- name: Create .env file
run: |
echo "BASE_URL=${{ vars.BASE_URL }}" >> apps/health_campaign_field_worker_app/.env
echo "MDMS_API_PATH=${{ vars.MDMS_API_PATH }}" >> apps/health_campaign_field_worker_app/.env
echo "TENANT_ID=${{ vars.TENANT_ID }}" >> apps/health_campaign_field_worker_app/.env
echo "ACTIONS_API_PATH=${{ vars.ACTIONS_API_PATH }}" >> apps/health_campaign_field_worker_app/.env
echo "SYNC_DOWN_RETRY_COUNT=${{ vars.SYNC_DOWN_RETRY_COUNT }}" >> apps/health_campaign_field_worker_app/.env
echo "RETRY_TIME_INTERVAL=${{ vars.RETRY_TIME_INTERVAL }}" >> apps/health_campaign_field_worker_app/.env
echo "CONNECT_TIMEOUT=${{ vars.CONNECT_TIMEOUT }}" >> apps/health_campaign_field_worker_app/.env
echo "RECEIVE_TIMEOUT=${{ vars.RECEIVE_TIMEOUT }}" >> apps/health_campaign_field_worker_app/.env
echo "SEND_TIMEOUT=${{ vars.SEND_TIMEOUT }}" >> apps/health_campaign_field_worker_app/.env
echo "CHECK_BANDWIDTH_API=${{ vars.CHECK_BANDWIDTH_API }}" >> apps/health_campaign_field_worker_app/.env
echo "HIERARCHY_TYPE=${{ vars.HIERARCHY_TYPE }}" >> apps/health_campaign_field_worker_app/.env
echo "ENV_NAME=${{ vars.ENV_NAME }}" >> apps/health_campaign_field_worker_app/.env
- name: Verify .env file
run: |
ls -l apps/health_campaign_field_worker_app/.env
cat apps/health_campaign_field_worker_app/.env
- name: Run APK build script
env:
BUILD_CONFIG: release # or profile depending on your choice
run: |
bash ./tools/generate-apk.sh
echo "Current working directory: $(pwd)"
echo "Listing all files at the current level:"
ls -l
# Step 8: Verify APK path and upload artifacts
- name: Check APK existence
run: |
echo "Looking for APK file"
if [ -f apps/health_campaign_field_worker_app/build/app/outputs/apk/release/app-release.apk ]; then
echo "APK found."
else
echo "APK not found in the expected path."
find . -name "app-release.apk"
exit 1
fi
# Archive the APK as a build artifact so it can be downloaded
- name: Upload APKs
uses: actions/upload-artifact@v3
with:
name: app-release-apk
path: apps/health_campaign_field_worker_app/build/app/outputs/apk/release/app-release.apk
- name: Upload .env as artifact
uses: actions/upload-artifact@v3
with:
name: env-file
path: apps/health_campaign_field_worker_app/.env
include-hidden-files: true