Can't deploy site from zip file using API

Hi,
Something wrong with deployment from zip file. It doesn’t show any error but It’s not building functions folder. When I open site, its not found. Site id is 924e8873-808a-48fe-9999-bbc3d676e04a. Do you have any idea?

Zip folder structure:
/build
/functions
/package.json
/netlify.toml

Hi @rromikas

If you wish to use functions, you need to deploy from a git repository or using the Netlify CLI. As stated here

To get started, designate a directory in your repository where Netlify can find your serverless functions

What makes you think I don’t understand?

I am using API to deploy. I don’t think building process is different when deploying from git repo or from extracted zip file.

I see you have amended your original post. This does make a difference.

Have you consulted the Deploy via API docs?

Yes, I have. I can see the deploy on neltify and can download files that are the same as were sent with HTTP request.

hi there, i wonder if this thread is helpful at all?

Hi, this thread didn’t help me. I tried zip project putting it in one folder before zipping and tried to just send project files to zipped folder. In either way, when I deploy it using API, it’s being built too fast, no error message, and the site doesn’t work.

Hi @rromikas,

Can you share the exact process that you’re following or share the zip that you’re uploading so we could check what might be going wrong?

I am uploading this:

Request url:
https://api.netlify.com/api/v1/sites/924e8873-808a-48fe-9999-bbc3d676e04a/deploys

headers:
“Content-Type”:“application/zip”
“Authorization”:“Bearer mytoken”

Building logs
3:50:56 PM: Creating deploy upload records
3:50:56 PM: Unpacking archive
3:50:57 PM: Starting post processing
3:50:57 PM: Post processing - HTML
3:50:57 PM: Post processing - header rules
3:50:57 PM: Post processing - redirect rules
3:50:57 PM: Post processing done
3:50:57 PM: Site is live :sparkles:

Hi @rromikas,

As mentioned in the docs:

A deploy from a zip file will enter post-processing mode straight after being created.

Thus, this won’t bundle the functions. It’s only useful to deploy fully static websites.

However, you can use file digest method:

But it’s more complicated than use a Git repo as you’d have to bundle the functions yourself, generate a SHA1 for each, add that to deploy request first and then send the actual file.

Additionally, you can simply use Netlify CLI to deploy as it will manage all this in one command.

I see…
Is there a way other users can deploy the app directly from my github repository and have continuous deployment from my repo?

I am currently using button with this url https://app.netlify.com/start/deploy?repository={github repo}

Hi @rromikas,

Would Build Hooks be of any help:

Build hooks will not help, because the app is linked to user’s own repository. I want that the other users’ apps would be linked to my repository.

Hi @rromikas,

The only way that’s possible is by actually letting users access your GitHub account and link the repo from the app.

I tried to update site with body:

{

    "build_settings": {
        "repo_url": "https://github.com/rromikas/myrepo",
        "repo_branch": "master",
        "repo_path": "rromikas/myrepo"
    }
}

but I guess it’s not a way to link site to external repo.

Hi @rromikas,

I don’t see the point in doing this. Even if it works, you won’t get any Git-based features like auto-deploy on push, PR commit checks, and anything of that sort as Netlify needs to be able to access the repo with the app installed. So basically, this would only be useful if you trigger the builds from the UI or via build hook, which might not be what you’re looking for.

Would you please explain your use case?

I am creating CMS that users deploys on their netlify account from landing page. I need that the user would be able to update his CMS when there is an update in CMS repository. I tried a way of deploying zip using API, but we figured out that it won’t work.

Hi @rromikas,

The only way this would work is if you can allow the users to have their own account or something on your website. I have seen many people use Netlify to deploy some kind of site builders or custom websites for clients which they connect to a single repo and deploy changes to that, which updates it for all their clients.

The approach you’re taking won’t work. There are still a few ways you could get this to work, though not quite automatic:

  1. You can allow your users to use your repo as a Git submodule.
  2. You can distribute your code as a library or something.

In both these cases, you’d have to ask the users to update it manually. There might be more ways to get this done, but the approach discussed above won’t work.

Thanks so much for your help. I got some ideas out of it.