FirebaseExtended / action-hosting-deploy

Automatically deploy shareable previews for your Firebase Hosting sites
https://firebase.google.com/docs/hosting/github-integration
Apache License 2.0
695 stars 202 forks source link

[BUG] Build fails with 'Flutter CLI not found' #290

Closed justyn closed 1 year ago

justyn commented 1 year ago

I've created a new Github Action to deploy on merge using firebase init hosting locally.

After pushing to GH and the build failing, I then added the env FIREBASE_CLI_EXPERIMENTS: webframeworks, as directed by the build error.

However, the build still fails, now with the error Error: Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again.

Config and build output below

Action config

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - main
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_LANGUAGEBUTLER }}'
          channelId: live
          projectId: languagebutler
        env:
          FIREBASE_CLI_EXPERIMENTS: webframeworks

Error message

Github Actions build output for step Run FirebaseExtended/action-hosting-deploy@v0

Run FirebaseExtended/action-hosting-deploy@v0
Verifying firebase.json exists
Setting up CLI credentials
Deploying to production site
  /usr/local/bin/npx firebase-tools@latest deploy --only hosting --project languagebutler --json
  npm WARN exec The following package was not found and will be installed: firebase-tools@12.3.0
  npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
  npm WARN deprecated har-validator@5.1.5: this library is no longer supported
  npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  ***
    "status": "error",
    "error": "Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again."
  ***
  ***
    "status": "error",
    "error": "Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again."
  ***

  The process '/usr/local/bin/npx' failed with exit code 1
  Retrying deploy with the --debug flag for better error output
  /usr/local/bin/npx firebase-tools@latest deploy --only hosting --project languagebutler --debug
  [2023-06-06T11:12:38.356Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
  [2023-06-06T11:12:38.473Z] [iam] checking project languagebutler for permissions ["firebase.projects.get","firebasehosting.sites.update"]
  [2023-06-06T11:12:38.475Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions [none]
  [2023-06-06T11:12:38.475Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions x-goog-quota-user=projects/languagebutler
  [2023-06-06T11:12:38.476Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions ***"permissions":["firebase.projects.get","firebasehosting.sites.update"]***
  [2023-06-06T11:12:38.549Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions 200
  [2023-06-06T11:12:38.549Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions ***"permissions":["firebase.projects.get","firebasehosting.sites.update"]***
  [2023-06-06T11:12:38.551Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler [none]
  [2023-06-06T11:12:38.752Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler 200
  [2023-06-06T11:12:38.752Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler ***"projectId":"languagebutler","projectNumber":"846052[13](https://github.com/justyn/translation_butler/actions/runs/5187845991/jobs/9350705901#step:3:14)2783","displayName":"LanguageButler","name":"projects/languagebutler","resources":***"hostingSite":"languagebutler"***,"state":"ACTIVE","etag":"1_dbf90df3-9eb6-49d5-9a8a-ef452837c772"***

     Thank you for trying our experimental support for Flutter Web on Firebase Hosting.
     While this integration is maintained by Googlers it is not a supported Firebase product.
     Issues filed on GitHub will be addressed on a best-effort basis by maintainers and other community members.

     Documentation: https://firebase.google.com/docs/hosting/frameworks/frameworks-overview
     File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
     Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

     We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X

  Error: Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again.
  [[20](https://github.com/justyn/translation_butler/actions/runs/5187845991/jobs/9350705901#step:3:23)23-06-06T11:12:38.356Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
  [2023-06-06T11:12:38.473Z] [iam] checking project languagebutler for permissions ["firebase.projects.get","firebasehosting.sites.update"]
  [2023-06-06T11:12:38.475Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions [none]
  [2023-06-06T11:12:38.475Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions x-goog-quota-user=projects/languagebutler
  [2023-06-06T11:12:38.476Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions ***"permissions":["firebase.projects.get","firebasehosting.sites.update"]***
  [2023-06-06T11:12:38.549Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions 200
  [2023-06-06T11:12:38.549Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/languagebutler:testIamPermissions ***"permissions":["firebase.projects.get","firebasehosting.sites.update"]***
  [2023-06-06T11:12:38.551Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler [none]
  [2023-06-06T11:12:38.752Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler 200
  [2023-06-06T11:12:38.752Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/languagebutler ***"projectId":"languagebutler","projectNumber":"84605[21](https://github.com/justyn/translation_butler/actions/runs/5187845991/jobs/9350705901#step:3:24)32783","displayName":"LanguageButler","name":"projects/languagebutler","resources":***"hostingSite":"languagebutler"***,"state":"ACTIVE","etag":"1_dbf90df3-9eb6-49d5-9a8a-ef452837c772"***

     Thank you for trying our experimental support for Flutter Web on Firebase Hosting.
     While this integration is maintained by Googlers it is not a supported Firebase product.
     Issues filed on GitHub will be addressed on a best-effort basis by maintainers and other community members.

     Documentation: https://firebase.google.com/docs/hosting/frameworks/frameworks-overview
     File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
     Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

     We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X

  Error: Flutter CLI not found, follow the instructions here https://docs.flutter.dev/get-started/install before trying again.

  The process '/usr/local/bin/npx' failed with exit code 1
  Error: The process '/usr/local/bin/npx' failed with exit code 1
  ***
    conclusion: 'failure',
    output: ***
      title: 'Deploy preview failed',
      summary: "Error: The process '/usr/local/bin/npx' failed with exit code 1"
    ***
  ***

Expected behavior

It should publish to Firebase Hosting

Actual behavior

It fails

justyn commented 1 year ago

I fixed this by adding the flutter-action GitHub Action.

So my firebase-hosting-merge.yml now looks like this:

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - main
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.10.3'
          channel: 'stable'
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_LANGUAGEBUTLER }}'
          channelId: live
          projectId: languagebutler
        env:
          FIREBASE_CLI_EXPERIMENTS: webframeworks

Presumably this should be added automatically when the file is created with firebase init hosting so I think this is a bug with that tool, rather than this one.