Skip to content

Instantly share code, notes, and snippets.

@marnixk
Created March 27, 2025 22:18
Show Gist options
  • Save marnixk/a5f487aa92e3cab058e702e109a53b56 to your computer and use it in GitHub Desktop.
Save marnixk/a5f487aa92e3cab058e702e109a53b56 to your computer and use it in GitHub Desktop.
name: Build & Deploy Flutter Web App
on:
push:
branches:
- main
- dev
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
MAIN_FILE: ${{ github.ref == 'refs/heads/main' && 'lib/main_prod.dart' || 'lib/main.dart' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.22.0'
- name: Get dependencies
run: flutter pub get
working-directory: code/flutter_frontend/
# - name: Test project
# run: flutter test
- name: Build release project
run: flutter build web --no-tree-shake-icons -t $MAIN_FILE
working-directory: code/flutter_frontend/
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: flutter_frontend_build
path: ./code/flutter_frontend/build/web
- name: Zip build output
run: zip -r ../../../../build.zip .
working-directory: ./code/flutter_frontend/build/web
- name: Move zip to infrastructure
run: mv build.zip infrastructure/artifacts/flutter_frontend_build.zip
- name: Configure git
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Commit and push changes
run: |
git add infrastructure/artifacts/flutter_frontend_build.zip
git commit -m 'Update Flutter build artifact'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment