Skip to content

Frontend: Add APK generation workflow #2

Frontend: Add APK generation workflow

Frontend: Add APK generation workflow #2

name: Deploy Flutter Frontend Apps
on:
push:
tags:
- 'v*'
paths:
- '.github/workflows/publish_frontend.yaml'
- 'core/**'
- 'frontend/**'
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Flutter packages
uses: actions/cache@v2
with:
path: |
~/.pub-cache
frontend/.dart_tool
core/.dart_tool
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.2'
channel: 'stable'
- name: Generate dotenv files
run: |
echo "BASE_URL=http://localhost:8080" > ./frontend/dotenv.dev
echo "BASE_URL=${{ secrets.BASE_URL }}" > ./frontend/dotenv.prod
- name: Get dependencies (frontend)
working-directory: ./frontend
run: flutter pub get
- name: Get dependencies (core)
working-directory: ./core
run: flutter pub get
- name: Run build_runner (core)
working-directory: ./core
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Run build_runner (frontend)
working-directory: ./frontend
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Build web app
working-directory: ./frontend
run: flutter build web --dart-define APP_ENV=production --base-href /down_the_aisle/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./frontend/build/web
- name: Build APK
working-directory: ./frontend
run: flutter build apk --release
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: release-apk
path: frontend/build/app/outputs/flutter-apk/app-release.apk
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: frontend/build/app/outputs/flutter-apk/app-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}