github.com/ratanraj/packer@v1.3.2/website/deploy/main.tf (about) 1 locals { 2 github_parts = ["${split("/", var.github_repo)}"] 3 github_full = "${var.github_repo}" 4 github_org = "${local.github_parts[0]}" 5 github_repo = "${local.github_parts[1]}" 6 } 7 8 /* 9 ------------------------------------------------------------------- 10 GitHub Resources 11 ------------------------------------------------------------------- 12 */ 13 14 provider "github" { 15 organization = "${local.github_org}" 16 } 17 18 // Configure the repository with the dynamically created Netlify key. 19 resource "github_repository_deploy_key" "key" { 20 title = "Netlify" 21 repository = "${local.github_repo}" 22 key = "${netlify_deploy_key.key.public_key}" 23 read_only = false 24 } 25 26 // Create a webhook that triggers Netlify builds on push. 27 resource "github_repository_webhook" "main" { 28 repository = "${local.github_repo}" 29 name = "web" 30 events = ["delete", "push", "pull_request"] 31 32 configuration { 33 content_type = "json" 34 url = "https://api.netlify.com/hooks/github" 35 } 36 37 depends_on = ["netlify_site.main"] 38 } 39 40 /* 41 ------------------------------------------------------------------- 42 Netlify Resources 43 ------------------------------------------------------------------- 44 */ 45 46 // A new, unique deploy key for this specific website 47 resource "netlify_deploy_key" "key" {} 48 49 resource "netlify_site" "main" { 50 name = "${var.name}" 51 52 repo { 53 repo_branch = "${var.github_branch}" 54 command = "cd website && bundle && middleman build --verbose" 55 deploy_key_id = "${netlify_deploy_key.key.id}" 56 dir = "website/build" 57 provider = "github" 58 repo_path = "${local.github_full}" 59 } 60 }