subosito / flutter-action

Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
MIT License
2.17k stars 193 forks source link

[Issue] Can't load flutter assets when build web platform #196

Closed cogivn closed 1 year ago

cogivn commented 1 year ago

Hi,

Thank you for creating awesome library. I tried to build a simple website but it failed to load the assets folder via CI but can build it at localhost Here is my configure and logs from Github CI. Can you help to check on it or let's me know if i configured wrong way :)

Thank you so much, Imgur

name: Deploy to GitHub Pages

on:
  push:
    # Update branch according from where you will be pushing the code
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      my_secret: ${{secrets.ACCESS_TOKEN}}

    steps:
      - uses: actions/checkout@v3
      - uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
      - run: flutter config --enable-web
      - run: flutter clean
      - run: flutter pub get
      - run: flutter pub run build_runner build --delete-conflicting-outputs
      - run: flutter pub run intl_utils:generate
      - run: flutter build web --release

      # Web deploy now is contained in build/web directory
      - run: |
          cd build
          mkdir web-deploy
          cd web-deploy
          #! Update with your Email ID associated with GitHub
          git config --global user.email <email ID>
          #! Update with your username associated with GitHub
          git config --global user.name <username>
          git config --global init.defaultBranch main
          git init
          # the repository to push the deploy into
          #! Update the following with your username and repository
          git remote add origin https://${{secrets.ACCESS_TOKEN}}@github.com/<username>/<repository>.git
          git fetch origin gh-pages
          git switch gh-pages
          # copy the build that is there in ROOT/build/web into ROOT/build/web-deploy
          cp -R ../web/* .
          git status
          git add .
          # add commit of the previous commit from main
          echo ""
          echo "Committing to gh-pages: ${{ github.event.head_commit.message }}"
          echo ""
          git commit -m "${{ github.event.head_commit.message }}"
          git push origin gh-pages
tk-nguyen commented 1 year ago

As I can see in the log, you don't have the directory images under assets on the main branch.

Also make sure the casing of monoLisa directory match what's shown on GitHub in your pubspec.yaml file.

cogivn commented 1 year ago

Hi @tk-nguyen,

Thank you for your reply. This is my example repo: https://github.com/cogivn/portfolio This is my pubspec.yaml

name: portfolio
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.0.1+1

environment:
  sdk: '>=2.18.2 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  cupertino_icons: ^1.0.5
  intl_utils:
    git: https://github.com/ThexXTURBOXx/intl_utils.git
  google_fonts: ^3.0.1
  asuka: ^2.0.1+3
  get_it: ^7.2.0
  intl: ^0.17.0
  flutter_bloc: ^8.1.1
  flutter_loggy: ^2.0.1
  flutter_svg: ^1.1.6
  flutter_screenutil: ^5.6.0
  auto_route: ^5.0.2
  freezed_annotation: ^2.2.0
  freezed: ^2.2.1
  shared_preferences: ^2.0.15
  flutter_secure_storage: ^6.0.0
  uuid: ^3.0.6
  mason: ^0.1.0-dev.35
  args: ^2.3.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.1
  build_runner: ^2.3.2
  flutter_gen_runner: ^5.1.0+1
  auto_route_generator: ^5.0.3

flutter:
  uses-material-design: true
  assets:
    - assets/images/
    - assets/icons/
  fonts:
    - family: MonoLisa
      fonts:
        - asset: assets/fonts/monoLisa/MonoLisa-Black.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-BlackItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-Bold.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-BoldItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-ExtraLight.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-ExtraLightItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-Light.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-LightItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-Medium.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-MediumItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-Regular.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-RegularItalic.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-Thin.ttf
        - asset: assets/fonts/monoLisa/MonoLisa-ThinItalic.ttf

flutter_gen:
  output: lib/generated/

  integrations:
    flutter_svg: true
    flare_flutter: false
    rive: false

  assets:
    enabled: true
    output:
      package_parameter_enabled: false
      style: dot-delimiter

  colors:
    enabled: true
    inputs:
      - assets/color/colors.xml

flutter_intl:
  enabled: true
  main_locale: 'en'
  arb_dir: assets/l10n

It works when I build it at localhost but fails with CI.

Thanks 👯

tk-nguyen commented 1 year ago

Add your assets/images folder to git, and change monoLisa to monolisa (lowercase l)

cogivn commented 1 year ago

Hi @tk-nguyen,

It fixed. i will close the threat. Thank you so much ❤️