Netlify functions not deploying when published via github

My Netlify functions don’t deploy when the site is built after a push to Github. But they do deploy when using the CLI netlify deploy --prod. Any idea what might be causing this?

Hi @ire, without seeing the repo it’s impossible to say. There’s no reason why they wouldn’t deploy unless you don’t specify a functions directory or the functions aren’t in there. Can you link to one of your builds? Also if the repo is public, can you share a link to it?

Hi @futuregerald! Thanks for the response!

I did specify the functions directory, here’s the repo:

And here’s a link to a build:

https://app.netlify.com/sites/caniuse-embed/deploys/5dcacd135864b00009ff2be6

Hi @ire , that deploy you linked to has a function in it
image
It also looks like that was your last successful deploy and the function in it is live in production now:

Hi! So I deployed from the CLI after that. Typically when the site is deployed from the github repository, there are no functions available. That deploy I sent you isn’t what is currently published.

Hi, your currently published deploy is: https://app.netlify.com/sites/caniuse-embed/deploys/5dcaf9a865e4301ecde098d2. I see the same thing for that.

image

I do see some of your deploys stuck in the ‘uploading’ state. Do you have any files in your deploy that are larger than 40Mbytes?

Hi @Dennis and @futuregerald

I found a better example, here’s a deploy preview: https://app.netlify.com/sites/caniuse-embed/deploys/5dcc9503ff18c70008ab683a (you can see that there are no deployed functions there)

This is based off of this PR: https://github.com/ireade/caniuse-embed/pull/14

I don’t think my deploy is larger than 40MB, it’s hard to tell locally because I have some local dependencies that are larger.

Hi @ire, the function is in a sub-directory under /functions, you need to put it in the root of the functions directory for it to be deployed. If you put it in a sub-directory then your build process has to output the final zip archive or bundled function in the root of your functions directory.

Thanks @futuregerald . I was just following the documentation from here:

You can use either a standalone .js file that exports a handler (e.g. functions/{function_name}.js ) or a folder with the same name as a .js file in it that exports a handler (e.g. functions/{function_name}/{function_name}.js ).

It’s fine though, I figured out a workaround that doesn’t need the netlify function at all. Thanks!