Skip to content

Added action for building apk #1

Added action for building apk

Added action for building apk #1

Workflow file for this run

name: Build APK with Custom Environment

Check failure on line 1 in .github/workflows/build-apk.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-apk.yml

Invalid workflow file

you may only define up to 10 `inputs` for a `workflow_dispatch` event
on:
workflow_dispatch:
inputs:
base_url:
description: 'Base URL for the service'
required: true
default: 'https://unified-dev.digit.org/'
type: string
mdms_api_path:
description: 'MDMS API Path'
required: true
default: 'egov-mdms-service/v1/_search'
type: string
tenant_id:
description: 'Tenant ID'
required: true
default: 'dev'
type: string
actions_api_path:
description: 'Actions API Path'
required: true
default: 'access/v1/actions/mdms/_get'
type: string
hierarchy_type:
description: 'Hierarchy Type'
required: true
default: 'ADMIN'
type: string
env_name:
description: 'Environment Name'
required: true
default: 'DEV'
type: choice
options:
- DEV
- QA
- UAT
- DEMO
- PROD
sync_down_retry_count:
description: 'Sync Down Retry Count'
required: false
default: '3'
type: string
retry_time_interval:
description: 'Retry Time Interval (seconds)'
required: false
default: '5'
type: string
connect_timeout:
description: 'Connection Timeout (milliseconds)'
required: false
default: '120000'
type: string
receive_timeout:
description: 'Receive Timeout (milliseconds)'
required: false
default: '120000'
type: string
send_timeout:
description: 'Send Timeout (milliseconds)'
required: false
default: '120000'
type: string
check_bandwidth_api:
description: 'Check Bandwidth API Path'
required: false
default: '/health-project/check/bandwidth'
type: string
build_type:
description: 'Build Type'
required: true
default: 'release'
type: choice
options:
- release
- profile
artifact_name:
description: 'Custom APK artifact name (optional)'
required: false
default: 'health-campaign-app'
type: string
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'
cache: true
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.0
- name: Install Global Dependencies
run: |
dart pub global activate mason_cli
dart pub global activate melos
- name: Create Environment Configuration
run: |
cat > apps/health_campaign_field_worker_app/.env << EOF
BASE_URL="${{ inputs.base_url }}"
MDMS_API_PATH="${{ inputs.mdms_api_path }}"
TENANT_ID="${{ inputs.tenant_id }}"
ACTIONS_API_PATH="${{ inputs.actions_api_path }}"
HIERARCHY_TYPE="${{ inputs.hierarchy_type }}"
ENV_NAME="${{ inputs.env_name }}"
SYNC_DOWN_RETRY_COUNT="${{ inputs.sync_down_retry_count }}"
RETRY_TIME_INTERVAL="${{ inputs.retry_time_interval }}"
CONNECT_TIMEOUT="${{ inputs.connect_timeout }}"
RECEIVE_TIMEOUT="${{ inputs.receive_timeout }}"
SEND_TIMEOUT="${{ inputs.send_timeout }}"
CHECK_BANDWIDTH_API="${{ inputs.check_bandwidth_api }}"
EOF
- name: Display Configuration
run: |
echo "Building APK with the following configuration:"
echo "Environment: ${{ inputs.env_name }}"
echo "Base URL: ${{ inputs.base_url }}"
echo "Tenant ID: ${{ inputs.tenant_id }}"
echo "Build Type: ${{ inputs.build_type }}"
- name: Install Project Dependencies
run: |
chmod +x ./tools/install_bricks.sh
./tools/install_bricks.sh
- name: Generate Code
run: |
cd apps/health_campaign_field_worker_app
dart run build_runner build --delete-conflicting-outputs
- name: Build APK
run: |
cd apps/health_campaign_field_worker_app
if [ "${{ inputs.build_type }}" == "release" ]; then
flutter build apk --release
elif [ "${{ inputs.build_type }}" == "profile" ]; then
flutter build apk -t lib/main_driver.dart --profile
fi
- name: Rename APK
run: |
cd apps/health_campaign_field_worker_app/build/app/outputs/flutter-apk
APK_NAME="${{ inputs.artifact_name }}-${{ inputs.env_name }}-${{ inputs.build_type }}.apk"
if [ "${{ inputs.build_type }}" == "release" ]; then
mv app-release.apk "$APK_NAME"
elif [ "${{ inputs.build_type }}" == "profile" ]; then
mv app-profile.apk "$APK_NAME"
fi
echo "APK_NAME=$APK_NAME" >> $GITHUB_ENV
- name: Upload APK Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.APK_NAME }}
path: apps/health_campaign_field_worker_app/build/app/outputs/flutter-apk/${{ env.APK_NAME }}
retention-days: 30
- name: Create Release Summary
run: |
echo "## 📱 APK Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Environment | ${{ inputs.env_name }} |" >> $GITHUB_STEP_SUMMARY
echo "| Base URL | ${{ inputs.base_url }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tenant ID | ${{ inputs.tenant_id }} |" >> $GITHUB_STEP_SUMMARY
echo "| Build Type | ${{ inputs.build_type }} |" >> $GITHUB_STEP_SUMMARY
echo "| APK Name | ${{ env.APK_NAME }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ APK has been successfully built and uploaded as an artifact." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📥 You can download the APK from the **Artifacts** section of this workflow run." >> $GITHUB_STEP_SUMMARY