FirebaseExtended / FirebaseExtended/action-hosting-deploy

[BUG] Github action does not find my project

Open
#298 5 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
809
Forks
232
PR merge metrics
No merged PRs in 30d

Description

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: firebase-tools@12.4.5
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/[31](https://github.com/MetricWire/research-m5/actions/runs/5613999017/job/15211305490#step:3:34)42
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": "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 ()
at ReadStream. (/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 ()
at ReadStream. (/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

Contributor guide

Open the contributing guide

Research direction

Start with the GitHub Actions configuration shown in the issue and trace how its projectId reaches the firebase-tools hosting:channel:deploy command. Reproduce the staging project ID case with debug output, then verify that the ID is passed unchanged and authentication no longer fails with the JSON parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, github-actions, typescript
Domain
ci-cd, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.