open-api: Site doesn't respond to event from webhook when created using createSite
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):
const Netlify = require('netlify')
const client = new Netlify(process.env.NETLIFY_TOKEN)
;(async () => {
const { id: deployKeyId } = await client.createDeployKey()
const site = await client.createSite({
body: {
repo: {
provider: 'gitlab',
deploy_key_id: deployKeyId,
repo_path: 'group/repo-name',
repo_branch: 'master',
}
}
})
})()
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 to true, 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).
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 5
- Comments: 16 (5 by maintainers)
@prestonlimlianjie as specified in the issue description, it works just fine with Github, but fails with Gitlab.
But it even works with terraform github 😆 Where it doesn’t for gitlab.
@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.
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?
Actually I just gave it a shot @chmelevskij and it works. Here are the steps I took (I’m using GitHub as my provider).
@bcomnes Any updates on this?