cli icon indicating copy to clipboard operation
cli copied to clipboard

netlify deploy --toml <path-to-toml> is missing

Open dan003400 opened this issue 2 years ago • 15 comments

I find it very very odd that simply supplying a path to the toml file is not something that is included in this cli, this blows my mind actually.

We are not using netlify builders and want to simply deploy from circleci but we are in a subdirectory of a monorepo.

All issues would be removed if you could simply supply a path to the config toml, I am not sure I have ever used a cli where this is not one of the most basic arguments to a command like deploy.

dan003400 avatar Oct 11 '21 20:10 dan003400

Hi @dan003400,

Thanks for reaching out. I believe the following command would fix your problem:

netlify deploy --config <path-to-toml>

ehmicky avatar Oct 11 '21 20:10 ehmicky

If that is actually an argument, it should be added here as it is not mentioned ANYWHERE in the docs or the README.

https://github.com/netlify/cli/blob/main/docs/commands/deploy.md

Very frustrating.

dan003400 avatar Oct 11 '21 20:10 dan003400

Error: Unexpected arguments: --config

I am not even sure why this is needed if I am in the working directory in circleci for the package within the monorepo.

When running the netlify deploy command, I am in the same directory as /build and netlify.toml exist, so why when running in circleci is the builder hanging up on an input needing to specify app id, etc if the netlify.toml exists in the directory?

image

dan003400 avatar Oct 11 '21 20:10 dan003400

Yes, you're correct, this is not working, although it should. It seems like we have missed allowing this CLI flag for the deploy command.

As you mention, when you are in a directory with a netlify.toml (or in any subdirectory), the configuration file will be used. A common way people solve this (since --config is not working at the moment) is to temporarily change the directory before running netlify deploy.

The issue you are highlighting right now though seems unrelated to netlify.toml. This prompt is not shown when netlify.toml is missing. Instead, it is shown when the site has not been linked yet (see documentation).

Please let me know if this helps.

ehmicky avatar Oct 11 '21 20:10 ehmicky

Can you explain why this is needed if a toml file exists with the Project ID included in it?

It seems it would be obvious that if the toml file exists, and the toml file has a project id, and that project id is known by netlify via the NETLIFY_AUTH_TOKEN env variable, it should do what ever link does behind the scenes, seems like an odd thing to do.... Not to mention I have no idea what that link command is even doing.

dan003400 avatar Oct 11 '21 21:10 dan003400

And more issues.....

image

How can we simply deploy via circleci with netlify-cli?

netlify link also completely ignores the fact that there is a netlify.toml file where it can get the answers to its user defined inputs? Why is this cli so hard to use in ci?

Having a toml file present is pointless....

dan003400 avatar Oct 11 '21 21:10 dan003400

The Netlify CLI needs the site ID. The netlify.toml contains the user build configuration, but not the site ID. The NETLIFY_AUTH_TOKEN environment variable contains authentication information, but not the site ID.

The site ID can be set using the following way:

  • Using the --site CLI flag to the deploy command. You can find the site ID under your site Settings (it is called "API ID" in the UI)
  • Using the NETLIFY_SITE_ID environment variable
  • Inside a .netlify/state.json file which is created by netlify init. This is the flow recommended in our documentation, but the other options should work as well.

ehmicky avatar Oct 11 '21 21:10 ehmicky

https://github.com/netlify/cli/issues/197

Also, your local script must be also adding the .netlify directory to the .gitignore, so if the state.json is the recommended way, why is this being done automatically?

the --site flag on the deploy command seems pointless as the link command would be hanging prior to even getting to this command unless providing a --site flag to the deploy command removed the need to use the link command all together?

Using the NETLIFY_SITE_ID is probably not the best, as the CI/CD for the project could be responsible for deploying multiple clients to Netlify, so setting something like this globally does really make much sense ever, specially in a monorepo.

dan003400 avatar Oct 11 '21 21:10 dan003400

unless providing a --site flag to the deploy command removed the need to use the link command all together?

Yes, exactly. The --site flag can be provided without having to perform netlify link. Based on the above, it appears this might solve your problem. :+1:

ehmicky avatar Oct 11 '21 21:10 ehmicky

Well that is frustrating, seems we should have used this to begin with rather than supplying the toml file path. The hanging user supplied inputs make it seem as if the toml file could not be found, as it "can" include the ID under [Settings] but that seems to be ignored completely, which is VERY odd.

dan003400 avatar Oct 11 '21 21:10 dan003400

Yes, you're correct. I'm glad it seems like this solved your initial problem. Could you please confirm this?

ehmicky avatar Oct 11 '21 21:10 ehmicky

Yes, --site is all that was needed. Seems the docs do not make this clear, nor does it make it clear that the [Settings] ID from toml is completely ignored...

dan003400 avatar Oct 11 '21 22:10 dan003400

Hi @dan003400, I'm glad to hear you've got things working. To better understand potential docs improvements, could you help me understand the following?

  • What caused you to try adding [Settings] ID to your netlify.toml file? We don't support this configuration option, so I'm hoping to figure out if there's a place where we need to remove an errant reference to it.
  • The --site flag is documented in the deploy command reference and in the output for netlify deploy help. Did you find either of these sources when looking for a --toml flag? Are there other places you checked for this information? Understanding where you looked and what you found can help us improve discoverability.

verythorough avatar Oct 12 '21 02:10 verythorough

Hi, I'm trying to target 2 different toml files depending on build mode. I'm working on Angular applications, with Scully for SSG. SSG is only triggered for master branch and tags, otherwise it's a default Angular build. When I'm building a default Angular App, I need Netlify to redirect every url to index.html. When I'm on SSG mode, the urls targets some real SSG folders and I don't want the default SPA redirection to index.html. I need also to redirect to language prefix when I'm on SSG mode. So if I could easily target a toml file or another depending on the type of build, it would be very helpful.

BenLune avatar Aug 05 '22 15:08 BenLune

I hope this command will work soon : netlify deploy --config <path-to-toml> Meanwhile I had to deal with file rename while CI process (netlify-default.toml OR netlify-scully.toml depending on context to netlify.toml).

BenLune avatar Aug 05 '22 16:08 BenLune

Closing as stale. Please re-open if needed

sarahetter avatar Sep 14 '23 16:09 sarahetter