firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 943 forks source link

predeploy not executing with multiple sites in the project #940

Closed anaganisk closed 5 years ago

anaganisk commented 6 years ago

Version info

5.0.0

Platform Information

Ubuntu 18.04 (Linux)

Steps to reproduce

The following firebase.json doesn't run the predeploy script

{
"hosting": [
    {
      "target": "app",
      "public": "app/build",
      "predeploy": ["npm --prefix app run build"],
      "ignore": ["firebase.json", "**/node_modules/**"],
      "rewrites": [
        {
          "source": "/**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "abc",
      "public": "abc/build"
    }
  ]
}

Expected behavior

Should run the predeploy script

Actual behavior

Predeploy script not executing, works on single site configuration

mbleigh commented 6 years ago

Yep, seems like a bug.

On Tue, Oct 9, 2018, 8:58 PM Anagani Sai Kiran <notifications@github.com wrote:

Version info

5.0.0 Platform Information

Ubuntu 18.04 (Linux) Steps to reproduce

The following firebase.json doesn't run the predeploy script

{"hosting": [ { "target": "app", "public": "app/build", "predeploy": ["npm --prefix app run build"], "ignore": ["firebase.json", "/node_modules/"], "rewrites": [ { "source": "/**", "destination": "/index.html" } ] }, { "target": "abc", "public": "abc/build" } ] }

Expected behavior

Should run the predeploy script Actual behavior

Predeploy script not executing, works on single site configuration

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/940, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAD_gRUesFwfpvL-KuLcrCwweU1j9v7ks5ujXBagaJpZM4XUiE3 .

laurenzlong commented 5 years ago

Internal bug reference: 122552632

bkendall commented 5 years ago

Leaving this open as it's an active bug.

brianpetro commented 5 years ago

🤞

Memeriaj commented 5 years ago

So what I believe is happening is that we collect all of the pre-deploys for all commands, then each command collects (possibly a list of) pre-deploys. However when a Hosting deploy deals with multiple Sites it is not adjusting the "top level" pre-deploy field, thus a single Site deploy executes the pre-deploy hook but when there are multiple Sites it doesn't find any.

This should be pretty straightforward, I'll try it out and test it at some point next week.

thdk commented 5 years ago

I've run into the same issues when using multiple targets for firebase hosting.

Temporary added my predeploy scripts into npm scripts in package.json:

"scripts": {
    "predeploy:site": "gulp site",
    "predeploy:blog": "gulp blog",
    "deploy:site": "npm run predeploy:site && firebase deploy --only hosting:site",
    "deploy:blog": "npm run predeploy:blog && firebase deploy --only hosting:blog"
  },

And run either npm run deploy:site or npm run deploy:blog

Memeriaj commented 5 years ago

Sorry I should have ping this thread and closed this a while back. I was waiting for my PR to actually be launched in a new version of the CLI (which is was with 879dd3283b97e8f28f2e333be653b24283018e13 on 2019-02-21).

EmilRais commented 5 years ago

@Memeriaj It seems that when you deployed that change you broke the feature. Each site's predeploy script are being run regardless of the deploy target being specified. We have two deploy targets "cms" and "web". Both deploy targets have predeployment needs so they each specify a predeploy script.

I want to deploy using the following command which is documented by firebase-tools: firebase deploy --only hosting:web

But when I run that command it will execute both cms' predeploy and web's predeploy before continuing to only deploy web.