1- # Create android release AAB
2- name : Android - Build
1+ # Reusable action to generate an android app from another repo
2+ # containing bundled web code
3+ name : Android Build
34on :
45 workflow_call :
56 inputs :
67 dist-path :
78 description : path to folder containing code to include in app. Omit if code not in a subfolder
89 type : string
10+ icon-path :
11+ description : path to a png image image to use for android icon
12+ type : string
13+ app-name :
14+ description : name of app to display on android device
15+ type : string
16+ default : Programming Club
17+ app-id :
18+ description : identifier of app for use on android device
19+ type : string
20+ default : club.programming.app
921jobs :
1022 android_build :
1123 runs-on : ubuntu-latest
2335 sparse-checkout : ${{ inputs.dist-path }}
2436 sparse-checkout-cone-mode : false
2537
26- - name : Move repo code in nested folder
27- if : ${{ inputs.dist-path }}
28- run : mv dist/${{ inputs.dist-path }}/* dist
29-
30- - name : Debug checkout files
31- run : |
32- echo $(ls)
33- echo $(ls dist)
34-
3538 - name : Setup Node
3639 uses : actions/setup-node@v4
3740 with :
@@ -42,12 +45,28 @@ jobs:
4245 - name : Install dependencies
4346 run : npm ci
4447
45- # TODO - generate assets
46- # TODO - allow capacitor overrides
48+ # If the exernal repo code is already in a folder, e.g. `build/index.html`, then it will be populated
49+ # with the extra top-level folder, `dist/build/index.html`. Move all subfolder files one level higher
50+ - name : Move repo code in nested folder
51+ if : ${{ inputs.dist-path }}
52+ run : mv dist/${{ inputs.dist-path }}/* dist
53+
54+ - name : Add app icon
55+ if : ${{ inputs.icon-path }}
56+ run : |
57+ mkdir assets
58+ cp dist/${{ inputs.icon-path }} assets/icon.png
59+ npx capacitor-assets generate --android
60+
61+ - name : Update capacitor config
62+ 63+ with :
64+ file : capacitor.config.json
65+ fields : " {'appId': '${{inputs.app-id}}', 'appName': '${{inputs.app-name}}'}"
66+
4767 - name : Add android platform
4868 run : npx cap add android
4969
50- # Re-sync as remote cache won't populate files during nx build command
5170 - name : Sync Capacitor
5271 run : npx cap sync
5372
7089 with :
7190 name : android
7291 path : ./android/app/build/outputs/apk/debug/app-debug.apk
73-
74- # - name: Build Android Release Bundle
75- # working-directory: ./android
76- # run: ./gradlew :app:bundleRelease
0 commit comments