Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Github action does not find my project #298

Open
clockwork189 opened this issue Jul 20, 2023 · 4 comments
Open

[BUG] Github action does not find my project #298

clockwork189 opened this issue Jul 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@clockwork189
Copy link

clockwork189 commented Jul 20, 2023

I am running into a very weird bug that has had me stumped. The issue that I have is if I use my staging project Id: "metricwire.com:api-project-737636097603" the firebase build will fail. My guess is because it is not getting the project Id in th e build phase as indicated by this part in the debug:

  /usr/local/bin/npx firebase-tools@latest hosting:channel:deploy pr8-github-actions --only app-staging --expires 7d --project *** --debug

I tried changing my projectId to anything else, literally anything else eg: "test", "staging", "abc" and while the build still fails (because I am using a non-existent project which I am aware of), the error log still shows:

  /usr/local/bin/npx firebase-tools@latest hosting:channel:deploy pr8-github-actions --only app-staging --expires 7d --project test --debug

So my current problem is that if my projectId is "metricwire.com:api-project-737636097603" I get the *** in the build step for --project and it fails otherwise it shows the proper project Id in the build debug.

My current workaround is to create a completely different firebase project for staging, but it is still curious that this issue occurs.

Action config

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
"on": pull_request
jobs:
    build_and_generate_previce:
        if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
        runs-on: ubuntu-latest
        environment: Development-App
        steps:
            - uses: actions/checkout@v3
            # - run: npm ci && npm run build
            - uses: FirebaseExtended/action-hosting-deploy@v0
              with:
                  repoToken: "${{ secrets.GITHUB_TOKEN }}"
                  firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}"
                  projectId: "metricwire.com:api-project-737636097603"
                  target: "app-staging"

Error message

/usr/local/bin/npx firebase-tools@latest hosting:channel:deploy pr8-github-actions --only app-staging --expires 7d --project *** --json
  npm WARN exec The following package was not found and will be installed: [email protected]
  npm WARN deprecated [email protected]: this library is no longer supported
  npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/[31](https://github.com/MetricWire/research-m5/actions/runs/5613999017/job/15211305490#step:3:34)42
  npm WARN deprecated [email protected]: 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": "Failed to authenticate, have you run \u001b[1mfirebase login\u001b[22m?"
  }
  {
    "status": "error",
    "error": "Failed to authenticate, have you run \u001b[1mfirebase login\u001b[22m?"
  }
  
  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 hosting:channel:deploy pr8-github-actions --only app-staging --expires 7d --project *** --debug
  [2023-07-20T17:22:48.040Z] > 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-07-20T17:22:48.060Z] SyntaxError: Unexpected token m in JSON at position 0
      at JSON.parse (<anonymous>)
      at ReadStream.<anonymous> (/home/runner/.npm/_npx/ba4f1959e38407b5/node_modules/google-auth-library/build/src/auth/googleauth.js:375:43)
      at ReadStream.emit (node:events:513:28)
      at ReadStream.emit (node:domain:489:12)
      at endReadableNT (node:internal/streams/readable:1[35](https://github.com/MetricWire/research-m5/actions/runs/5613999017/job/15211305490#step:3:38)9:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
  
  Error: Failed to authenticate, have you run firebase login?
  [2023-07-20T17:22:48.040Z] > 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-07-20T17:22:48.060Z] SyntaxError: Unexpected token m in JSON at position 0
      at JSON.parse (<anonymous>)
      at ReadStream.<anonymous> (/home/runner/.npm/_npx/ba4f1959e38407b5/node_modules/google-auth-library/build/src/auth/googleauth.js:[37](https://github.com/MetricWire/research-m5/actions/runs/5613999017/job/15211305490#step:3:40)5:43)
      at ReadStream.emit (node:events:513:28)
      at ReadStream.emit (node:domain:489:12)
      at endReadableNT (node:internal/streams/readable:1359:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
  
  Error: Failed to authenticate, have you run firebase login?
  
  The process '/usr/local/bin/npx' failed with exit code 1
  Error: The process '/usr/local/bin/npx' failed with exit code 1

Expected behavior

Successful Build

Actual behavior

Build Fails

@clockwork189 clockwork189 added the bug Something isn't working label Jul 20, 2023
@Psycarlo
Copy link

Any fixes for this one?

@seth-acuitymd
Copy link

I wonder if this isn't actually something with the Firebase Action, but GitHub Actions itself thinking that your projectID is a secret value? If you pass it in as an environment variable to the workflow and call it that way, does anything change?

Something like

jobs:
    build_and_generate_previce:
        if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
        env:
          project-id: "metricwire.com:api-project-737636097603"
        runs-on: ubuntu-latest
        environment: Development-App
        steps:
            - uses: actions/checkout@v3
            # - run: npm ci && npm run build
            - uses: FirebaseExtended/action-hosting-deploy@v0
              with:
                  repoToken: "${{ secrets.GITHUB_TOKEN }}"
                  firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}"
                  projectId: ${{ env.project-id }}
                  target: "app-staging"

@Psycarlo
Copy link

I wonder if this isn't actually something with the Firebase Action, but GitHub Actions itself thinking that your projectID is a secret value? If you pass it in as an environment variable to the workflow and call it that way, does anything change?

Something like


jobs:

    build_and_generate_previce:

        if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"

        env:

          project-id: "metricwire.com:api-project-737636097603"

        runs-on: ubuntu-latest

        environment: Development-App

        steps:

            - uses: actions/checkout@v3

            # - run: npm ci && npm run build

            - uses: FirebaseExtended/action-hosting-deploy@v0

              with:

                  repoToken: "${{ secrets.GITHUB_TOKEN }}"

                  firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}"

                  projectId: ${{ env.project-id }}

                  target: "app-staging"

I don't think so because I have another project with the projectId like that and runs fine.

@chirag-biradar
Copy link

@clockwork189 did you find any fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants