简体   繁体   中英

How to programatically deploy to Firebase Hosting?

The problem

I have configured a project that currently is possible to deploy to Firebase Hosting multi sites by using the Firebase CLI.

The problem is that currently I am doing this manually. And I want to programatically do this, and if possible, using NodeJS.

The steps of my system:

  • User uploads a.zip file with a index.html
  • I extract and check the.zip file with NodeJS
  • I deploy the files to Firebase Hosting

Currently I am doing like this:

  1. First create the site page with, where game-project-id-unique should be unique:

firebase hosting:sites:create game-project-id-unique

  1. Then, add the target/project ID linked to the game, where game-id is defined by us:

firebase target:apply hosting game-id game-project-id-unique

  1. Add to the firebase.json the configuration of the file (array):
 {
      "target": "game-id",
      "public": "games/game-id",
      "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
 }
  1. Then, to publish:

firebase deploy --only hosting

Possible solutions?

I have researched here, I have found out that is possible to use the API-DEPLOY or the CLOUD BUILD , but this is not enough to guide me into the programatically approach, without the need of a human in-between.

Is there a way of doing this? Is it even possible?

You can certainly just write a script that invokes the CLI. This is very common.

You can also use the Firebase Hosting REST API , but in my opinion that is going to be a lot more work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM