w9jds / firebase-action

GitHub Action for interacting with Firebase
MIT License
922 stars 198 forks source link

Error: Failed to get Firebase project <project_name>. Please make sure the project exists and your account has permission to access it #192

Open aseem-heg opened 1 year ago

aseem-heg commented 1 year ago
    steps:
      - uses: actions/checkout@v3

      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
          cache: true

      - name: Build Web App
        run: flutter build web --dart-define=env=dev --dart-define=domain=pangea-dev-314501.uc.r.appspot.com

      - name: w9jds Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy
        env:
          GCP_SA_KEY: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}

I am trying to deploy flutter app to Firebase. Deployment works fine from my local machine. But on GHA I get error Error: Failed to get Firebase project <project_name>. Please make sure the project exists and your account has permission to access it

My GCP sv_account has permissions - Firebase Hosting Admin & Service Account User .

felixgabler commented 1 year ago

For me it fails with Error: Failed to get details for project: <PROJECT_NAME>. My service account also has all the necessary permissions. Could these be related?

hotrush commented 1 year ago

Same

karanbangia commented 11 months ago

Facing the same issue, the service account has all the necessary permission but still i am getting this error, but

vincenz5 commented 11 months ago

Same. I'm wondering if the credentials secret should be the whole JSON from the service account or maybe just the key.

peter-palmer commented 6 months ago

Hi there,

I've come across the issue you're facing and found a solution that worked for me. The problem seems to be related to authentication with Google Cloud Platform (GCP) credentials when deploying to Firebase using GitHub Actions. Here's how I resolved it:

  1. On your local machine, run firebase login. This will authenticate your Firebase CLI and give you a token. Please ensure you're logged into the correct Firebase project.

  2. You'll receive a token that looks something like this: 1//03MosCTldCCgYIARPPGAMSTkF-L2IrO-W55quB6Pwn6w1335SwtTSXYbGGxleferiRdVSXTUL1x7QUkJaTKEGW-WaVpYFpSJK (Do not use this one as it's an example).

  3. Convert this token to base64. You can use an online tool like https://www.base64encode.org/ for this purpose.

  4. Next, go to the environment variables section of your GitHub repository by navigating to Settings -> Secrets and variables -> Actions -> New repository secret. Create two new repository secret named GCP_SA_KEY and GCP_SA_KEY_BASE64 paste the base64-encoded token you obtained as its value in this last one. The plain token in the GCP_SA_KEY.

  5. Modify your GitHub Actions YAML file to use this token for authentication with Firebase. Here's how the updated part of your workflow should look:

# Deploying the functions to firebase
- name: Deploy to Firebase
  uses: w9jds/firebase-action@master
  with:
    args: deploy --only functions --token ${{ secrets.GCP_SA_KEY }}
  env:
    GCP_SA_KEY: ${{ secrets.GCP_SA_KEY_BASE64 }}
  1. Save your changes and rerun your GitHub Actions workflow. This should resolve the issue and successfully deploy your Flutter app to Firebase.

I hope this solution works for you as well. Good luck!

aixaCode commented 6 months ago

Not sure if anyone still has this problem, but using personal token with GitHub Actions didn't seem very secure, and the actual issue was with permissions for the service account.

I got it fixed by granting access to "run as" the App Engine default Service Account"([PROJECT_ID]@appspot.gserviceaccount.com).

These roles and permissions did the trick for me:

Screenshot 2024-03-12 223103 Screenshot 2024-03-12 223134

Just putting it out there in case someone else runs into the same hurdle.