workflow: upgarded to use latest actions and commands #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build an Android APK | |
on: | |
push: | |
paths: | |
- '.github/workflows/build-android.yml' | |
- 'ionic_ui_templates/**' | |
- '!ionic_ui_templates/**/*.md' | |
- '!ionic_ui_templates/ios/**' | |
branches: | |
- main | |
defaults: | |
run: | |
working-directory: ionic_ui_templates | |
jobs: | |
build-apk: | |
permissions: | |
contents: write | |
name: Build Android APK | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup Web environment to install packages. | |
- name: Setup Web environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
# only required if project is not in the root | |
cache-dependency-path: ionic_ui_templates/package-lock.json | |
- name: Restore node_modules from cache | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} | |
restore-keys: ${{ runner.os }}-node-modules- | |
# Setup Java environment in order to build the Android app. | |
- name: Setup Java 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
# Setup gradle using official gradle action | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
add-job-summary: 'on-failure' | |
- name: Install Ionic CLI | |
run: npm install -g @ionic/cli | |
- name: Install packages | |
run: npm ci --legacy-peer-deps | |
- name: Build the ionic project for Android | |
run: ionic capacitor build android --prod --no-open | |
- name: Build Android debug APK | |
working-directory: ionic_ui_templates/android | |
run: ./gradlew assembleDebug | |
- name: Save apk file as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ionic_ui_templates | |
path: ionic_ui_templates/android/app/build/outputs/apk/debug/app-debug.apk |