skip to Main Content

I am trying to deploy a Flutter web app to Firebase hosting using the FirebaseExtended/action-hosting-deploy action and the experimental webframeworks flag. Here is my GitHub workflow file:

name: Deploy to Firebase Hosting on merge
on:
  push:
    branches:
      - main
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable
          flutter-version: 3.19.0
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: ${{ secrets.GITHUB_TOKEN }}
          firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_FLUTTER_FAST }}
          channelId: live
          projectId: flutter-fast
          target: flutter-ast-viewer
        env:
          FIREBASE_CLI_EXPERIMENTS: webframeworks  

Whenever this workflow runs, the web page gets updated but it’s blank and the following error appears on the network tab:

GET https://flutter-ast-viewer.web.app/flutter_bootstrap.js net::ERR_ABORTED 404 (Not Found)

If I deploy the app using the command line (firebase deploy), everything works fine.

Firebase.json

{
  "hosting": {
    "site": "flutter-ast-viewer",
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-east1"
    }
  }
}

.firebaserc

{
  "projects": {
    "default": "flutter-ast-viewer"
  }
}


I tried a bunch of other things but it seems like something gets broken in the GitHub action. Manual deploys work fine.

"error": "Must supply a "public" or "source" directory or at least one rewrite or redirect in each "hosting" config."

Error: Hosting configs should only include either "site" or "target", not both.

"error": "Can only specify "source" or "public" in a Hosting config, not both"

Error: Directory ‘build/web’ for Hosting does not exist.

2

Answers


  1. I have the same problem, this was my solution:
    On webindex.html look at this:
    [enter image description here][1]
    [1]: https://i.sstatic.net/wijVuZzY.png
    change

    <script src="flutter_bootstrap.js" async></script>
    

    for

    <script src="./flutter_bootstrap.js" async></script>
    

    I’ts because the path its wrong, that works for me

    Login or Signup to reply.
  2. This is my flutter action, you can check it, be careful with the flutter versions
    name: Analyze, Build and Deploy

    "on":
      push:
        branches:
          - test
    
    jobs:
      semantic-pull-request:
        name: "Semantic"
        uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1
    
      build:
        name: Build
        needs: [semantic-pull-request]
        runs-on: ubuntu-latest
        steps:
          - name: 📚 Git Checkout
            uses: actions/checkout@v3
          - name: 🐦 Setup Flutter
            uses: subosito/flutter-action@v2
            with:
              channel: "stable"
              flutter-version: 3.22.2
          - name: 📦 Install Dependencies
            run: |
              flutter pub get
          - name: 🛠️ Build the application
            run: flutter build web
          - name: ⬇️ Archive Production Artifact
            uses: actions/upload-artifact@master
            with:
              name: build
              path: build/web
    
      deploy:
        name: "Deploy"
        runs-on: ubuntu-latest
        needs: build
        steps:
          - name: 📚 Checkout repo
            uses: actions/checkout@v3
          - name: ⬇️ Download Artifact
            uses: actions/download-artifact@master
            with:
              name: build
              path: build/web
          - name: 🎯 Deploy to firebase
            uses: FirebaseExtended/action-hosting-deploy@v0
            with:
              repoToken: "${{ secrets.GITHUB_TOKEN }}"
              firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_DANCE_CLUB_COMUNA_8 }}"
              channelId: test
              projectId: dance-club-comuna-8
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search