How can I automate the build and deployment of a signed Android app made with Ionic (default config) and Capacitor using GitHub Actions? My app is fully functional, and I want to streamline the deployment process.
How can I automate the build and deployment of a signed Android app made with Ionic (default config) and Capacitor using GitHub Actions? My app is fully functional, and I want to streamline the deployment process.
Share Improve this question asked Feb 6 at 18:04 Romb38Romb38 317 bronze badges1 Answer
Reset to default 0I just set up a working CI pipeline to build and create a release of an Android APK using Ionic and Capacitor. During my research, I found limited documentation, so I'm sharing my setup here.
To create this CI, I referred to the Ionic documentation on building and syncing.
For generating a signed APK, you'll need a keystore file. I created mine using Android Studio. In Android Studio, navigate to Build → Generate Signed App Bundle or APK, select APK, and click Create new....
The CI secrets correspond to the following:
secrets.KEYSTORE
: The keystore (.jks
) file encoded in base64. On Debian, I usedbase64 <keyfile>.jks
to generate it.secrets.KEYSTORE_PASS
: The password for the keystore file.secrets.KEYSTOREALIAS
: The alias name you chose.secrets.KEYSTOREALIAS_PASS
: The password set for the alias.
name: Ionic CI/CD with Cypress
on:
pull_request:
types: [closed]
jobs:
build-release-apk:
runs-on: ubuntu-24.04
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Ionic and Capacitor dependencies
run: npm install -g @ionic/cli @capacitor/core @capacitor/cli
- name: Install app dependencies
run: |
npm install
npm run build
- name: Build Ionic app
env:
KEYSTOREALIAS_PASS: ${{ secrets.KEYSTOREALIAS_PASS }}
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
KEYSTOREALIAS: ${{ secrets.KEYSTOREALIAS }}
KEYSTORE: ${{ secrets.KEYSTORE }}
run: |
echo "$KEYSTORE" | base64 --decode > android/official.jks
npx cap sync
npx cap build android --keystorepath official.jks \
--keystorepass "$KEYSTORE_PASS" \
--keystorealias $KEYSTOREALIAS \
--keystorealiaspass "$KEYSTOREALIAS_PASS" \
--androidreleasetype APK
- name: Release with Notes
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
android/app/build/outputs/apk/release/app-release-signed.apk