44

There are over 10,000 files in this artifact, consider creating an archive before upload to improve the upload performance.

sem1Colon
  • 446
  • 1
  • 4
  • 7

4 Answers4

111

I had this issue deploying a node app to Azure App Services.

I fixed it by adding a zip and an unzip step.

zip step is

  - name: Zip artifact for deployment
    run: zip release.zip ./* -r

unzip step is

  - name: unzip artifact for deployment
    run: unzip release.zip

Add the zip step after the build step and before Upload artifact step like this

  - name: npm install, build, and test
    run: |
      npm install
      npm run build --if-present
      npm run test --if-present

  - name: Zip artifact for deployment
    run: zip release.zip ./* -r

  - name: Upload artifact for deployment job
    uses: actions/upload-artifact@v2
    with:
      name: node-app
      path: release.zip

Then the unzip step is added after the download artifact step and before the deploy step like this.

steps:
  - name: Download artifact from build job
    uses: actions/download-artifact@v2
    with:
      name: node-app
      
  - name: unzip artifact for deployment
    run: unzip release.zip

  - name: 'Deploy to Azure Web App'
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
Steve
  • 1,823
  • 1
  • 13
  • 14
  • 13
    great answer, i was looking for a way to speed up my azure deployments, and this was it. I went from a 40 minute average deployment, to a 5 minute deployment, so your answer is much appreciated! – Austin Howard Oct 06 '21 at 22:14
  • 12
    Be careful with hidden files/dirs (i.e. those who start with a dot), as it won't pick them. In my case I had to manually add those (`zip -r release.zip * .env .next`) – helpse Dec 11 '21 at 00:20
  • 2
    @helpse Thanks, I needed to add the ".next" for my next js app – Larry Flewwelling Dec 21 '21 at 01:58
  • 6
    You may also delete the zip file after the unzip step by running `rm release.zip` – Periplo Jan 06 '22 at 00:39
  • 1
    Great answer. In case anyone is using this answer together with the `working-directory` option, and is receiving an error `From directory doesn't exist`, please refer to my Q&A [here](https://stackoverflow.com/q/72051607/197591). – Neo Apr 29 '22 at 00:56
  • 1
    This was super helpful! If you want to include hidden files too, use `zip release.zip . -r` – Rajath Kedilaya Jun 21 '22 at 17:09
  • Is there a performance benefit to doing this technique even if you don't have such a large number of files to be uploaded? I.e., if you have, say 50-100 files to be uploaded into an archive, does this technique speed-up the upload or download process? – Jason Frank Jul 22 '22 at 18:30
  • My two cents: if your zip archive contains symlinks and some already exist when running unzip, you'll get an error. I had to use `unzip -o -u packages-build.zip` to ignore the error and overwrite the files successfully. – slax57 Jan 03 '23 at 15:09
  • may i add you dont need to unzip the release folder you can just add it to the deploy job as the zip to deploy `publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_52DFB46EC5A2427FBB1FFC3D2FA0860F }} package: release.zip` – alvinMemphis Mar 07 '23 at 22:35
  • None of this worked for me. I had to convert to tar and then I kept getting permission denied when trying to create the release.zip file. – Sean Anderson Mar 26 '23 at 23:06
  • Do make sure this is using this `build: runs-on: ubuntu-latest` you will get a powershell error trying to zip with `windows-latest`. – domshyra Apr 02 '23 at 23:10
10

I also faced this issue when deploying a react based app to Azure App service.

To add to the answer written by @steve, If the App service instance is windows based, one can use Powershell's Compress-Archive.

In build steps - zipping

Compress-Archive . release.zip

In deploy steps - unzipping

Expand-Archive release.zip

or

unzip release.zip

if the deployment script is using bash

Aravind Samala
  • 139
  • 1
  • 5
  • I think `Compress-Archive * release.zip` and `Expand-Archive release.zip -DestinationPath .` will must better to avoid additional folder been created. – Will Huang Mar 25 '23 at 01:33
0

I found on my case, I was using a windows hosting environment, and found the easy solution was adding the "./dist" (my output dir) instead of "." (no quotes in the file) so that it did not archive the node_modules folder. It still has an install and build command, but i've removed test, and altered this line. Mine now deploys in about 1 minute. I'm not certain what the ramifications of not archiving everything is with these artifacts as i'm new to Git, but this was able to resolve my issue, in the event someone else "just needs to get something hosted or else" as well. See code:

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: node-app
          path: ./dist
-2

You can zip all the files using below command and then upload the zip folder as your artifacts.

zip artifact.zip <generated_files>/*
Sam-Sundar
  • 511
  • 1
  • 4
  • 12