FirebaseExtended / FirebaseExtended/action-hosting-deploy

Add a way to use different filename for firebase.json

Open
#333 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
809
Forks
232
PR merge metrics
No merged PRs in 30d

Description

### The use case you're trying to solve

We ha ve a monorepo with multiple firebase projects in it. We have the following layout of monorepo:

```
.
├── fireabse.project1.json — (firebase configurations for each project in the root)
├── fireabse.project2.json
├── apps (where apps is stored. Firabse functions is also an app)
│ ├── frontendApp1
│ ├── frontendApp2
│ ├── functionsApp1
│ └── functionsApp2
├── libs (— here libs go)
└── projects (here live firebase projects with it's configurations)
├── project1
└── project2
├── firestore.rules
└── rules-testing.spec.ts
```

The structure of `fireabse.project1.json` is usually like this:

```json
{
"firestore": {
"rules": "projects/project1/firestore.rules",
"indexes": "projects/project1/firestore.indexes.json"
},
"hosting": {
"public": "dist/apps/frontendApp1",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"functions": [
{
"codebase": "functionsApp1",
"source": "dist/apps/functionsApp1",
"predeploy": "nx build functionsApp1",
"runtime": "nodejs18",
"ignore": ["*.local"]
},
{
"codebase": "functionsApp2",
"source": "dist/apps/functionsApp2",
"predeploy": "nx build functionsApp2",
"runtime": "nodejs18",
"ignore": ["*.local"]
}
],
"emulators": {
}
}
```

Note that this file lays in the root, and have different path for `src` and `dist`.

We usually un all firebase commands just directly passing firebase.json to it

```bash
firebase --config=firebase.project1.json
```

However this action has a slightly diffrent api than native firebase command and it doesn't allow to pass a path to the config file.
Instead entrypoint should be a subpath with `firebase.json` in it

### Change to the action that would solve that use case

I think it could be usefull if entryPoint property may accept path to the config, so the logic would detect if the file path passed than use this path, if directory is passed, so `cd` to this directory and look for default `firebase.josn` in it.

```js
// pseudocode

let configFile;

if (isDir(entryPoint)) {
changeDir(entryPoint);
configFile = 'firebase.json'
} else {
configFile = entryPoint
}
```

UPD: i've just tried to workaround the isuue by moving `firebase.project1.json` into `projects/project1/firebase.json` and changing paths in the file accordingly. That lead to a path like `../../dist/apps/frontendApp1` and fail with `Error: ../../dist/apps/frontendApp1 is outside of project directory`. So this improvement even more viable.

Contributor guide

Open the contributing guide

Research direction

Locate the action's entryPoint handling and compare it with the native firebase --config behavior described in the issue. Reproduce the monorepo case using a root-level firebase.project1.json and verify that directory entry points still use firebase.json while file entry points work with the existing project paths. Done means both forms deploy without the outside-project-directory failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, github-actions, typescript
Domain
ci-cd, cloud
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.