Open mojavelinux opened 5 years ago
I also find it questionable that all the docs for using createSite with a repo all say "it's a bit complicated to create a repo object, please contact support". Come on. This operation is central to the API and automation. Please document it properly. And it's not that complicated, as my example above reveals. We just need it to actually work.
We have improvements coming to the repos/hooks setup process that have been recently launched that need to be documented. I'll give this a deeper read during the week.
That's great to hear, Bret. I'm ready to help test. Just call on me. πββοΈ
@mojavelinux I have not forgotten about this, but I haven't addressed it yet. Sorry for the wait.
Thanks for the update, Bret!
Is there any updates on this or ways how to help?
@bcomnes Any updates on this?
Actually I just gave it a shot @chmelevskij and it works. Here are the steps I took (I'm using GitHub as my provider).
@prestonlimlianjie as specified in the issue description, it works just fine with Github, but fails with Gitlab.
I am seeing this behaviour with GitHub as far as I can tell. I am using Terraform so maybe there's something in there / user-error, but it seems to be as-described. The project sets up and runs a deployment at-first, but then changes to the upstream repository are not picked up by netlify and subsequent deployments are not triggered.
Hi @mojavelinux @chmelevskij @prestonlimlianjie @peabnuts123. First of all, sorry for the late response.
The repositories webhooks cannot be enabled from the Netlify API. The best way to enable them is either to:
npm init
)We understand being able to setup repositories webhooks via the Netlify API would be very useful. Unfortunately we cannot provide this feature at the moment for security reasons. The incoming webhooks are setup by the Netlify web app using the GitHub/GitLab/Bitbucket API under the hood. This requires credentials that are obtained from your browser and would be more problematic to do via the Netlify API while maintaining security compliance.
We understand though that this is suboptimal if you're trying to programmatically create Sites. So I've created a request that you can follow here to allow performing this action via our JavaScript client. Would this work for you?
I think most of the people end up on this issue following the terraform provider https://github.com/terraform-providers/terraform-provider-netlify/issues/14
It's quite interesting that it does work for github but not gitlab.
Wouldn't js client use the createSite
operation as well then and have the same issue?
At the moment our CLI is opening a browser window to ask for the OAuth credentials for GitHub. I believe for GitLab and Bitbucket this requires some manual setup though at the moment. That being said, we do want to decrease as much setup as possible for any Git providers in the future, to make it as developer-friendly as possible.
The reason I come to this issue is mostly that the behaviour seems bugged, rather than unimplemented. Note that I am still using the Terraform provider, so there is still some room for error in that fact. Upon creating a site, a connection to GitHub is made and added to the site, and a build is triggered (and succeeds), however, no further upstream changes trigger that build. However, visiting the website in a browser looks like the connection is set up and working correctly. If I manually remove the connection and re-add it using the browser, the resultant config looks the same, however, upstream changes are correctly registered subsequently. I could understand if the Netlify provider in Terraform was not actually able to set up the connection to GitHub, and then I had to log in manually and set that up myself, but seems like the application is created in a strange, bugged state.
@peabnuts123 we might have a bug there that shows the GitHub connection as setup in the UI even though it is not. However as far as I understand it the GitHub connection is not supposed to be setup when following those steps.
But it even works with terraform github π Where it doesn't for gitlab.
When I create a site with a linked GitLab repository using the createSite operation, the site doesn't respond to incoming events (push or merge request) from the webhook (https://api.netlify.com/hooks/gitlab).
Here's the API call I'm using to create the site (which contains a netlify.toml file):
If I click "Edit settings", then "Link to a different repository", the site starts responding to events from the webhook. However, there doesn't seem to be any change in the site settings (at least as reported by the API).
Is the createSite API not capable of setting up a site with CI properly? If so, what setting am I missing?
I also noticed that even if the repository is public, and I set the
public_repo
property totrue
, Netlify still reports the repository as private (as indicated by the lock icon next to the repository URL on the Build Settings page and confirmed by the API).