Hello,
I am trying to deploy a new site using the Netlify API inside a Rails aplication, all is done with this code:
def create_netlify_app
netlify_auth = "Bearer " + ENV['NETLIFY_ACCESS_TOKEN']
url = URI("https://api.netlify.com/api/v1/deploy_keys")
deploy_key = HTTParty.post(url, :headers => { "Authorization" => netlify_auth})
url = URI("https://api.netlify.com/api/v1/sites")
body = {
"name": @channel.repository_name,
"custom_domain": @channel.domain,
"notification_email": "fagianijunior@gmail.com",
"repo": {
"provider": "github",
"id": ENV['GITHUB_REPO_ID'],
"repo_path": "autoforce/automaker",
"private": true,
"branch": @channel.repository_name,
"cmd": "bundle install && yarn install",
"dir": "build/",
"deploy_key_id": deploy_key['id']
}
}
The Git repository is from a organization, my user has access to it and the Netlify plugin (Authorized GitHub Apps) has permission too.
the site has created but the build fall with:
9:16:25 AM: Build ready to start
9:16:29 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
9:16:29 AM: build-image tag: v3.3.2
9:16:29 AM: buildbot version: a2bab682ae0761baa4d123ebd00c57be933655dc
9:16:30 AM: Fetching cached dependencies
9:16:30 AM: Failed to fetch cache, continuing with build
9:16:30 AM: Starting to prepare the repo for build
9:16:30 AM: git ref refs/heads/pontanegra-pontanegra does not exist or you do not have permission
9:16:30 AM: Failing build: Failed to prepare repo
9:16:30 AM: failed during stage ‘preparing repo’: git ref refs/heads/pontanegra-pontanegra does not exist
But the repository exist, if I go to netlify dashboard and reselect the branch, it is permited and the build go, can anyone say me what I am doing wrong?
This is the return, on the first time I created the site on netlify.
{"id"=>"10c759d5-e528-4de6-8fee-c8dfc83eb7e1",
"site_id"=>"10c759d5-e528-4de6-8fee-c8dfc83eb7e1",
"plan"=>"nf_team_dev",
"ssl_plan"=>nil,
"premium"=>false,
"claimed"=>true,
"name"=>"pontanegra-pontanegra",
"custom_domain"=>"pontanegra.com.br",
"domain_aliases"=>[],
"password"=>nil,
"notification_email"=>"fagianijunior@gmail.com",
"url"=>"http://pontanegra.com.br",
"admin_url"=>"https://app.netlify.com/sites/pontanegra-pontanegra",
"deploy_id"=>"",
"build_id"=>"5dcae9ca1148baf9b077abcc",
"deploy_url"=>"http://.pontanegra-pontanegra.netlify.com",
"state"=>"current",
"screenshot_url"=>nil,
"created_at"=>"2019-11-12T17:20:10.254Z",
"updated_at"=>"2019-11-12T17:20:10.317Z",
"user_id"=>"5c49c090cc50d9bb179245b1",
"error_message"=>nil,
"ssl"=>false,
"ssl_url"=>"https://pontanegra.com.br",
"force_ssl"=>nil,
"ssl_status"=>nil,
"max_domain_aliases"=>100,
"build_settings"=>
{"cmd"=>"bundle install && yarn install",
"dir"=>"build/",
"env"=>{},
"created_at"=>"2019-11-12T17:20:10.310Z",
"updated_at"=>"2019-11-12T17:20:10.310Z",
"public_repo"=>false,
"private_logs"=>nil,
"allowed_branches"=>["pontanegra-pontanegra"],
"functions_dir"=>nil,
"installation_id"=>nil,
"skip_prs"=>nil,
"review_untrusted_builds"=>nil,
"base_rel_dir"=>true,
"provider"=>"github",
"repo_type"=>"git",
"repo_url"=>"https://github.com/autoforce/automaker",
"repo_branch"=>"pontanegra-pontanegra",
"repo_path"=>"autoforce/automaker",
"base"=>nil,
"deploy_key_id"=>"5dcae9b0cd359201eec3bced"},
"processing_settings"=>
{"css"=>{"bundle"=>true, "minify"=>true}, "js"=>{"bundle"=>true, "minify"=>true}, "images"=>{"optimize"=>true}, "html"=>{"pretty_urls"=>true}, "skip"=>true},
"prerender"=>nil,
"prerender_headers"=>nil,
"deploy_hook"=>"https://api.netlify.com/hooks/github",
"published_deploy"=>nil,
"managed_dns"=>true,
"jwt_secret"=>nil,
"jwt_roles_path"=>"app_metadata.authorization.roles",
"account_slug"=>"fagianijunior",
"build_settings"=>
{"cmd"=>"bundle install && yarn install",
"dir"=>"build/",
"env"=>{},
"created_at"=>"2019-11-12T17:20:10.310Z",
"updated_at"=>"2019-11-12T17:20:10.310Z",
"public_repo"=>false,
"private_logs"=>nil,
"allowed_branches"=>["pontanegra-pontanegra"],
"functions_dir"=>nil,
"installation_id"=>nil,
"skip_prs"=>nil,
"review_untrusted_builds"=>nil,
"base_rel_dir"=>true,
"provider"=>"github",
"repo_type"=>"git",
"repo_url"=>"https://github.com/autoforce/automaker",
"repo_branch"=>"pontanegra-pontanegra",
"repo_path"=>"autoforce/automaker",
"base"=>nil,
"deploy_key_id"=>"5dcae9b0cd359201eec3bced"},
"processing_settings"=>
{"css"=>{"bundle"=>true, "minify"=>true}, "js"=>{"bundle"=>true, "minify"=>true}, "images"=>{"optimize"=>true}, "html"=>{"pretty_urls"=>true}, "skip"=>true},
"prerender"=>nil,
"prerender_headers"=>nil,
"deploy_hook"=>"https://api.netlify.com/hooks/github",
"published_deploy"=>nil,
"managed_dns"=>true,
"jwt_secret"=>nil,
"jwt_roles_path"=>"app_metadata.authorization.roles",
"account_slug"=>"fagianijunior",
"account_name"=>"Carlos Fagiani Junior's team",
"account_type"=>"Starter",
"capabilities"=>
{"title"=>"Netlify Team Free",
"asset_acceleration"=>true,
"form_processing"=>true,
"cdn_propagation"=>"partial",
"build_gc_exchange"=>"buildbot-gc",
"build_node_pool"=>"buildbot-external-ssd",
"domain_aliases"=>true,
"secure_site"=>false,
"prerendering"=>true,
"proxying"=>true,
"ssl"=>"custom",
"rate_cents"=>0,
"yearly_rate_cents"=>0,
"cdn_network"=>"free_cdn_network",
"ipv6_domain"=>"cdn.makerloop.com",
"branch_deploy"=>true,
"managed_dns"=>true,
"geo_ip"=>true,
"split_testing"=>true,
"id"=>"nf_team_dev"},
"paid_individual_site_subscription"=>false,
"dns_zone_id"=>nil,
"identity_instance_id"=>nil,
"use_functions"=>nil,
"parent_user_id"=>nil,
"automatic_tls_provisioning"=>nil,
"disabled"=>nil,
"lifecycle_state"=>"active",
"id_domain"=>"10c759d5-e528-4de6-8fee-c8dfc83eb7e1.netlify.com",
"use_lm"=>nil,
"build_image"=>"xenial",
"automatic_tls_provisioning_expired"=>false,
"analytics_instance_id"=>nil,
"analytics_locations_enabled"=>false}