Is it possible to deploy only the new/changed files via API?

I have looked at the forum for similar questions and tried using sha and filenames in the deployment, in attempt to uploading only the new/changed files but with no success. Would anyone be able to suggest a working method? Thanks!

@ken_inclr It is not possible, new deployments of a site must contain all files.

There’s a plugin for “netlify-plugin-jekyll-cache” which can cache any directory and make it available at the start of the next build process.

Even though it’s named as a Jekyll plugin, you can customise the target directory and use it however you like.

If you target your publish directory, then all you need is logic in your build process to specifically update the necessary files instead of running a complete build.

@ZachD That doesn’t prevent all the files being deployed though, it just means they aren’t being “built every time”.

Deployment wise, the end result is the same, all the same build artifacts were there to be checked/deployed.

There’s no way to push incremental partial site changes via API.

1 Like

The plugin allows you to have all of the pieces of the puzzle to work with. Your previous deployment, and your entire codebase.

You can then decide which new files go into your publish dir, which need updating and which stay the same. You need to write the logic for that decision, but you have all the pieces to work with.

I have started to use this for previewing CMS content changes where only a handful of records change. It reduced build time from 1 min down to 20 seconds.

This is still incorrect. If a file is missing from the publish directory, it won’t be published.

That is slightly misleading (though you might have meant the same as below). Uploading a single file is definitely possible and that’s how Netlify works:

Yes, exactly.

The plugin restores the previous publish dir. Then in your build process you decide which files to add, which to leave the same, and even which to remove, if you like.

Sounds like a lot of work for most build configurations, unless you’ve got a very special use case. Most build tools would simply generate a publish directory which you can directly deploy without having to make all these comparisons.

Yes, it might be a lot of work in some configurations. But it is possible, which is what the OP wanted to know.

Never having used the API before, I wasn’t aware you could self provide the sha’s of files, (without the files themselves needing to exist - I’d presumed it would want to see the files itself), but it makes sense that the sha’s of unchanged files are all it requires to still be atomic.

I’d assumed this user simply wanted to make a request to the Netlify API to add/remove/update a subset of files and have Netlify sort it out, e.g. without engineering a custom solution. Which as indicated by the requirement of always telling Netlify about all files, is something that doesn’t exist.

Thanks for the responses everyone. That helped clarify what I needed.

Thank you for coming back and letting us know the advice of the community and our team helped you.