Build APK #7
This file contains hidden or 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 APK | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| url: | |
| description: 'Website URL' | |
| required: true | |
| default: 'https://deckk.it' | |
| type: string | |
| app_name: | |
| description: 'App Name' | |
| required: true | |
| default: 'deckk.it' | |
| type: string | |
| package_name: | |
| description: 'Package Name' | |
| required: true | |
| default: 'com.deckk.it' | |
| type: string | |
| favicon_url: | |
| description: 'Favicon URL (optional)' | |
| required: false | |
| type: string | |
| build_type: | |
| description: 'Build Type' | |
| required: true | |
| default: 'release' | |
| type: choice | |
| options: | |
| - release | |
| - debug | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up keystore | |
| run: | | |
| if [ "${{ github.event.inputs.build_type }}" = "release" ]; then | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > keystore.jks | |
| else | |
| touch keystore.jks | |
| fi | |
| - name: Build Docker image | |
| if: ${{ github.event.inputs.build_type == 'release' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: webview-builder | |
| build-args: WEBSITE_URL=${{ github.event.inputs.url }},APP_NAME=${{ github.event.inputs.app_name }},PACKAGE_NAME=${{ github.event.inputs.package_name }},FAVICON_URL=${{ github.event.inputs.favicon_url }},BUILD_TYPE=${{ github.event.inputs.build_type }} | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| - name: Build Docker image (debug) | |
| if: ${{ github.event.inputs.build_type == 'debug' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: webview-builder | |
| build-args: WEBSITE_URL=${{ github.event.inputs.url }},APP_NAME=${{ github.event.inputs.app_name }},PACKAGE_NAME=${{ github.event.inputs.package_name }},FAVICON_URL=${{ github.event.inputs.favicon_url }},BUILD_TYPE=${{ github.event.inputs.build_type }} | |
| - name: Extract APK from container | |
| run: | | |
| CONTAINER_ID=$(docker create webview-builder) | |
| docker cp "$CONTAINER_ID:/project/app/build/outputs/apk/${{ github.event.inputs.build_type }}/app-${{ github.event.inputs.build_type }}.apk" ./${{ github.event.inputs.app_name }}.apk | |
| docker rm -v "$CONTAINER_ID" | |
| - name: Verify APK exists | |
| run: | | |
| if [ ! -f "${{ github.event.inputs.app_name }}.apk" ]; then | |
| echo "Error: APK file not found" | |
| exit 1 | |
| fi | |
| ls -lh ${{ github.event.inputs.app_name }}.apk | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ github.event.inputs.app_name }}.apk | |
| path: ${{ github.event.inputs.app_name }}.apk | |
| - name: Cleanup secrets | |
| if: always() | |
| run: | | |
| rm -f keystore.jks |