FirebaseExtended / action-hosting-deploy

Automatically deploy shareable previews for your Firebase Hosting sites
https://firebase.google.com/docs/hosting/github-integration
Apache License 2.0
695 stars 202 forks source link

Deploying from github action way slow then local deployment #231

Closed ricardovanlaarhoven closed 2 years ago

ricardovanlaarhoven commented 2 years ago

The use case you're trying to solve

I would like a faster way to simply deploy stuff to the hosting. Deplying 174 files of 11.5MB in total takes up 1m and 40s. Since deploying it on a PR is part of my test strategy. I would like to speed things up

Change to the action that would solve that use case

Perhaps caching npm will help? npm WARN exec The following package was not found and will be installed: firebase-tools@11.8.0 I'm not sure what else makes it slow? The application is already build. And deploying it locally never takes more then 10 seconds

blopker commented 2 years ago

For us, installing firebase-tools is the slowest part of the whole deploy process. From what I can tell, there are 2 potential ways to fix it.

1) Build in caching to this action. This will be slow on the first run, but the next run will have the tool cached already so npm doesn't need to do all the work to install it. See https://github.com/actions/cache

2) Use the REST API (https://firebase.google.com/docs/hosting/api-deploy). This would require pretty much a full rewrite of the action, but would be the fastest since it could be done without installing any packages at all. Most languages have pretty good built-in support for HTTP requests.

blopker commented 2 years ago

I also just thought of a 3rd option. Use the standalone binary release of firebase-tools: https://github.com/firebase/firebase-tools/#standalone-binary

This would be faster (especially with caching) since it doesn't require npm to install and instead is just one large binary.

ricardovanlaarhoven commented 2 years ago

It seems like installing is not the slowest part, but uploading is. Which is weird since uploading is super fast locally

ricardovanlaarhoven commented 2 years ago

I don't know why the timestamps were weird, but you were right, adding this removed 3 minutes from my action, thnx!


      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'npm'
blopker commented 2 years ago

Nice find. Yeah, the action runs in 11s now, down from 1m 40s, 90% speedup!