If you want to deploy github private repo to netlify, using netlify API. Here is a step by step procedure.
- Firstly you need to get the id of the github repo, which you want to deploy. know how to get the github id here.
- After getting repo id, You have to get public_key & id using netlify api. know how to get the public_key here.
- After getting public_key, Using github api
https://api.github.com/repos/:owner/:repo/keys
POST public_key in the body section as shown below
{
"title":"test",
"key":<your public key>,
"read_only":false
}
- After this step deploy the site using
https://api.netlify.com/api/v1/sites
. Use POST method by body as below
{
"name":<your site name>, // ex: test
"repo":{
"provider":"github",
"id":<your github repo id>,
"repo":"<your username>/<your repo>",
"private":true,
"branch":"main",
"deploy_key_id":<your deploy key id>
}
}
In the above deploy_key_id is the id you got in the 2nd step. 5. Boom!! congratulations, your site has been deployed successfully.
if you found any trouble feel free to add issue