Mobile CI/CD Workflows
This guide provides detailed information about the GitHub Actions workflows that power the CI/CD pipeline for the PersiaNation mobile application.
Workflow Overview
Section titled “Workflow Overview”The mobile app uses several GitHub Actions workflows to ensure code quality, automate builds, and streamline releases:
| Workflow | Trigger | Purpose | Duration |
|---|---|---|---|
test.yml | Push, PR | Unit & integration tests | ~3-5 min |
lint-ts.yml | Push, PR | TypeScript linting | ~2-3 min |
type-check.yml | Push, PR | TypeScript type checking | ~1-2 min |
e2e-android.yml | Push, PR | End-to-end testing | ~10-15 min |
preview.yml | Hotfix branch | Preview builds & OTA updates | ~5-8 min |
new-github-release.yml | Git tags | GitHub releases | ~1-2 min |
Quality Assurance Workflows
Section titled “Quality Assurance Workflows”1. TypeScript Type Checking (type-check.yml)
Section titled “1. TypeScript Type Checking (type-check.yml)”Purpose: Ensures type safety across the entire codebase.
name: Type Checkon: [push, pull_request]
jobs: type-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 18.x - uses: pnpm/action-setup@v2 with: version: latest - run: pnpm install - run: pnpm type-checkWhat it checks:
- TypeScript compilation errors
- Type mismatches and inconsistencies
- Missing type definitions
- Interface compatibility
2. Linting (lint-ts.yml)
Section titled “2. Linting (lint-ts.yml)”Purpose: Enforces code style and catches common issues.
name: Lint TypeScripton: [push, pull_request]
jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - uses: pnpm/action-setup@v2 - run: pnpm install - run: pnpm lintWhat it checks:
- ESLint rule violations
- Code formatting consistency
- Import/export issues
- Unused variables and imports
- React/React Native specific issues
3. Unit & Integration Tests (test.yml)
Section titled “3. Unit & Integration Tests (test.yml)”Purpose: Runs the complete test suite to ensure functionality.
name: Teston: [push, pull_request]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - uses: pnpm/action-setup@v2 - run: pnpm install - run: pnpm testWhat it tests:
- Component rendering and behavior
- Utility function correctness
- API integration logic
- Navigation flows
- State management
4. End-to-End Testing (e2e-android.yml)
Section titled “4. End-to-End Testing (e2e-android.yml)”Purpose: Tests complete user workflows on Android emulator.
name: E2E Androidon: [push, pull_request]
jobs: e2e-android: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - uses: pnpm/action-setup@v2 - name: Setup Android SDK uses: android-actions/setup-android@v2 - name: Run E2E tests run: pnpm e2e:androidWhat it tests:
- Complete user registration flow
- Authentication and login
- Core app navigation
- Critical user interactions
- App performance under load
Build & Deployment Workflows
Section titled “Build & Deployment Workflows”1. Preview Builds (preview.yml)
Section titled “1. Preview Builds (preview.yml)”Purpose: Creates quick preview builds for testing hotfixes and urgent changes.
name: Previewon: pull_request: branches: [hotfix] push: branches: [hotfix]
jobs: update: name: EAS Update runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - name: Check for EXPO_TOKEN run: | if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then echo "EXPO_TOKEN secret required" exit 1 fi
- uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 18.x - uses: pnpm/action-setup@v2 with: version: latest - uses: expo/expo-github-action@v8 with: eas-version: latest token: ${{ secrets.EXPO_TOKEN }}
- run: pnpm install - name: Create preview uses: expo/expo-github-action/preview@v8 with: command: eas update --autoFeatures:
- Triggers on hotfix branch changes
- Creates EAS Update for immediate testing
- Posts preview QR code in PR comments
- Uses staging channel for safe testing
- Automatic deployment without manual intervention
2. GitHub Release Creation (new-github-release.yml)
Section titled “2. GitHub Release Creation (new-github-release.yml)”Purpose: Automatically creates GitHub releases when version tags are pushed.
name: New GitHub Releaseon: push: tags: ["*"]
jobs: release: name: New GitHub Release runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: ncipollo/release-action@v1 with: generateReleaseNotes: true draft: falseFeatures:
- Triggered by any git tag push
- Automatically generates release notes from commits
- Creates public GitHub release
- Links to build artifacts and changelogs
Workflow Configuration
Section titled “Workflow Configuration”Required Secrets
Section titled “Required Secrets”Configure these secrets in your GitHub repository settings:
# Repository Settings > Secrets and Variables > Actions
EXPO_TOKEN # Expo account authentication tokenGOOGLE_SERVICES_JSON # Android Google Services configurationAPPLE_TEAM_ID # iOS development team identifierANDROID_KEYSTORE_PASSWORD # Android app signing keystore passwordANDROID_KEY_ALIAS # Android signing key aliasANDROID_KEY_PASSWORD # Android signing key passwordEnvironment Variables
Section titled “Environment Variables”# Automatically set by workflowsGITHUB_TOKEN # GitHub API access (auto-provided)RUNNER_OS # Operating system (ubuntu-latest)NODE_VERSION # Node.js version (18.x)PNPM_VERSION # Package manager version (latest)Workflow Triggers
Section titled “Workflow Triggers”Push Triggers
Section titled “Push Triggers”# Runs on every push to any branchon: [push]
# Runs on push to specific brancheson: push: branches: [main, staging, develop]
# Runs on tag pusheson: push: tags: ['v*', 'release/*']Pull Request Triggers
Section titled “Pull Request Triggers”# Runs on PR creation and updateson: [pull_request]
# Runs on PR to specific brancheson: pull_request: branches: [main, staging] types: [opened, synchronize, reopened]Manual Triggers
Section titled “Manual Triggers”# Allows manual workflow executionon: workflow_dispatch: inputs: environment: description: "Environment to deploy to" required: true default: "staging" type: choice options: - staging - productionWorkflow Optimization
Section titled “Workflow Optimization”Caching Strategies
Section titled “Caching Strategies”# Cache node_modules for faster installs- name: Cache dependencies uses: actions/cache@v3 with: path: ~/.pnpm-store key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-
# Cache Expo CLI and tools- name: Cache Expo uses: actions/cache@v3 with: path: ~/.expo key: ${{ runner.os }}-expo-${{ hashFiles('**/app.config.ts') }}Parallel Job Execution
Section titled “Parallel Job Execution”jobs: test: strategy: matrix: platform: [ios, android] environment: [staging, production] runs-on: ubuntu-latest steps: - name: Test ${{ matrix.platform }} on ${{ matrix.environment }} run: pnpm test:${{ matrix.platform }}Conditional Execution
Section titled “Conditional Execution”# Only run on specific file changes- name: Run tests if: contains(github.event.head_commit.modified, 'src/') run: pnpm test
# Skip workflows on documentation changes- name: Check for docs changes if: "!contains(github.event.head_commit.message, '[skip ci]')" run: pnpm buildMonitoring & Debugging
Section titled “Monitoring & Debugging”Workflow Status Monitoring
Section titled “Workflow Status Monitoring”# View workflow runsgh run list --workflow="test.yml"
# Get specific run detailsgh run view <run-id>
# Download workflow logsgh run download <run-id>Common Workflow Issues
Section titled “Common Workflow Issues”1. Build Timeouts
Section titled “1. Build Timeouts”# Increase timeout for long-running jobsjobs: build: timeout-minutes: 30 # Default is 6 hours runs-on: ubuntu-latest2. Secret Access Issues
Section titled “2. Secret Access Issues”# Debug secret availability- name: Check secrets run: | if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then echo "EXPO_TOKEN not available" exit 1 fi3. Dependency Installation Failures
Section titled “3. Dependency Installation Failures”# Retry failed installations- name: Install dependencies run: | for i in {1..3}; do pnpm install && break || sleep 15 doneWorkflow Performance Metrics
Section titled “Workflow Performance Metrics”| Metric | Target | Typical |
|---|---|---|
| Type Check | < 2 min | 1.5 min |
| Linting | < 3 min | 2.5 min |
| Unit Tests | < 5 min | 4 min |
| E2E Tests | < 15 min | 12 min |
| EAS Update | < 8 min | 6 min |
Best Practices
Section titled “Best Practices”1. Workflow Organization
Section titled “1. Workflow Organization”- Keep workflows focused on single responsibilities
- Use reusable actions for common tasks
- Organize jobs logically with clear dependencies
- Use meaningful names and descriptions
2. Security
Section titled “2. Security”- Never log sensitive information
- Use secrets for all credentials
- Limit workflow permissions to minimum required
- Regularly rotate authentication tokens
3. Performance
Section titled “3. Performance”- Cache dependencies and build artifacts
- Use matrix builds for parallel execution
- Skip unnecessary jobs based on file changes
- Optimize Docker image usage
4. Reliability
Section titled “4. Reliability”- Add retry logic for flaky operations
- Use appropriate timeouts
- Handle edge cases gracefully
- Monitor workflow success rates
Advanced Workflows
Section titled “Advanced Workflows”Custom EAS Build Workflow
Section titled “Custom EAS Build Workflow”name: Custom EAS Buildon: workflow_dispatch: inputs: platform: type: choice options: [ios, android, all] profile: type: choice options: [development, staging, production]
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - uses: pnpm/action-setup@v2 - uses: expo/expo-github-action@v8 with: token: ${{ secrets.EXPO_TOKEN }}
- run: pnpm install - name: Build app run: | eas build \ --platform ${{ github.event.inputs.platform }} \ --profile ${{ github.event.inputs.profile }} \ --non-interactiveAutomated Store Submission
Section titled “Automated Store Submission”name: Store Submissionon: release: types: [published]
jobs: submit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: expo/expo-github-action@v8 with: token: ${{ secrets.EXPO_TOKEN }}
- name: Submit to stores run: | eas submit \ --platform all \ --profile production \ --latest \ --non-interactiveRelated Documentation
Section titled “Related Documentation”- Mobile App Release & CI/CD: Complete release process guide
- GitHub Actions Documentation: Official GitHub Actions docs
- Expo GitHub Actions: Expo-specific workflow examples