Vipin
Back

29 Nov 2026 · 3 min read

Shipping an Android APK on every push with GitHub Actions and Capacitor

How PillBridge goes from a React web app to an installable Android APK without Android Studio on my laptop: one GitHub Actions workflow, about 50 lines of YAML.

PillBridge is a medication-reminder app that links patients with their caregivers. It started as a React + Vite web app, but the people who need reminders most want something on their phone, not a browser tab.

Rewriting it in React Native would have meant two codebases. Instead I wrapped the existing web app with Capacitor and let GitHub Actions build the Android APK. Now every push to master produces an APK I can download and install, and I never have to open Android Studio.

How Capacitor fits in

Capacitor takes the built web app (the dist/ folder) and puts it inside a native Android project that shows it in a WebView. Native plugins (splash screen, status bar, biometric login) are called from JavaScript.

The whole connection is one config file:

// capacitor.config.ts
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.pillbridge.app',
  appName: 'PillBridge',
  webDir: 'dist',               // Vite's build output
  server: { androidScheme: 'https' },
  plugins: {
    SplashScreen: { launchShowDuration: 2000, launchAutoHide: true },
    NativeBiometric: { useFallback: true, maxAttempts: 5 },
  },
};

export default config;

Locally, the loop is: npm run build → npx cap sync android → open the android/ folder and build. CI runs those same steps.

The workflow

# .github/workflows/build-android.yml
name: Build Android APK

on:
  push:
    branches: [master]
  workflow_dispatch:   # also allow a manual "Run workflow" button

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'

      - run: npm ci

      - name: Build web app
        run: npm run build
        env:
          VITE_API_BASE_URL: ${{ vars.API_BASE_URL }}

      - name: Sync Capacitor
        run: npx cap sync android

      - uses: actions/setup-java@v4
        with:
          distribution: 'zulu'
          java-version: '21'

      - uses: android-actions/setup-android@v3

      - name: Build APK
        working-directory: android
        run: |
          chmod +x ./gradlew
          ./gradlew assembleDebug

      - uses: actions/upload-artifact@v4
        with:
          name: PillBridge-debug
          path: android/app/build/outputs/apk/debug/app-debug.apk

Step by step:

  1. Node + npm ci: a clean install from the lockfile, with the npm cache so repeat runs are faster.
  2. npm run build: Vite builds the web app. VITE_* variables are baked into the bundle at build time, so the API URL has to be set here, not when the app runs.
  3. npx cap sync android: copies dist/ into the Android project and updates the native plugins.
  4. Java 21 + Android SDK: the runner has neither by default. setup-android installs the SDK and accepts the licences.
  5. ./gradlew assembleDebug: the actual Android build. The chmod +x matters: if gradlew was committed from Windows, it loses its executable bit and the step fails with "permission denied".
  6. upload-artifact: the APK appears on the workflow run page as a downloadable zip.

Things that tripped me up

  • Mismatched Java versions. Newer Android Gradle Plugin versions need a newer JDK. If the build fails with an "unsupported class file version" error, it's almost always the java-version line.
  • cap sync before Gradle, every time. If you skip it, the APK contains the previous web build. The app installs fine and just shows old code, which is confusing to debug.
  • HTTPS everywhere. With androidScheme: 'https', the WebView blocks requests to a plain http:// backend. The production API has to be HTTPS.
  • Build-time env vars are public. Anything in VITE_* ends up in the JavaScript bundle inside the APK, so only public values (API base URL, OAuth client IDs) go there, never secrets. I keep them in repository variables rather than hard-coding them in the YAML, so they can change without a commit.

What I'd add next

This pipeline builds a debug APK, which is fine for testers but not for the Play Store. The next steps are:

  • Release signing: store the keystore as a base64 GitHub secret, decode it in the job, and run ./gradlew assembleRelease (or bundleRelease for an AAB).
  • Versioning: set versionCode from github.run_number so every build can be installed over the previous one.
  • A quick check before the build: lint and unit tests, so a broken commit fails in one minute instead of after a five-minute Gradle build.
  • Releases: on a tag push, attach the APK to a GitHub Release so testers have a permanent download link.

Takeaway

For a web-first app, Capacitor + GitHub Actions is the cheapest way to get onto Android: one codebase, no local Android setup, and a fresh APK after every push. The pipeline is small enough to read in a minute, which makes it easy to trust and to extend.