2018-05-07 17:59:38 -04:00
|
|
|
locals {
|
|
|
|
github_parts = ["${split("/", var.github_repo)}"]
|
|
|
|
github_full = "${var.github_repo}"
|
|
|
|
github_org = "${local.github_parts[0]}"
|
|
|
|
github_repo = "${local.github_parts[1]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
GitHub Resources
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
provider "github" {
|
|
|
|
organization = "${local.github_org}"
|
2019-05-09 14:21:26 -04:00
|
|
|
|
|
|
|
version = "~> 2.0.0"
|
2018-05-07 17:59:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Configure the repository with the dynamically created Netlify key.
|
|
|
|
resource "github_repository_deploy_key" "key" {
|
|
|
|
title = "Netlify"
|
|
|
|
repository = "${local.github_repo}"
|
|
|
|
key = "${netlify_deploy_key.key.public_key}"
|
|
|
|
read_only = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a webhook that triggers Netlify builds on push.
|
|
|
|
resource "github_repository_webhook" "main" {
|
|
|
|
repository = "${local.github_repo}"
|
|
|
|
events = ["delete", "push", "pull_request"]
|
|
|
|
|
|
|
|
configuration {
|
|
|
|
content_type = "json"
|
|
|
|
url = "https://api.netlify.com/hooks/github"
|
2019-05-09 13:54:23 -04:00
|
|
|
insecure_ssl = false
|
2018-05-07 17:59:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
depends_on = ["netlify_site.main"]
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
Netlify Resources
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2019-05-09 14:21:26 -04:00
|
|
|
provider "netlify" {
|
|
|
|
version = "~> 0.1.0"
|
|
|
|
}
|
|
|
|
|
2018-05-07 17:59:38 -04:00
|
|
|
// A new, unique deploy key for this specific website
|
|
|
|
resource "netlify_deploy_key" "key" {}
|
|
|
|
|
|
|
|
resource "netlify_site" "main" {
|
2019-05-09 13:54:23 -04:00
|
|
|
name = "${var.name}"
|
|
|
|
custom_domain = "${var.custom_site_domain}"
|
2018-05-07 17:59:38 -04:00
|
|
|
|
|
|
|
repo {
|
|
|
|
repo_branch = "${var.github_branch}"
|
|
|
|
command = "cd website && bundle && middleman build --verbose"
|
|
|
|
deploy_key_id = "${netlify_deploy_key.key.id}"
|
|
|
|
dir = "website/build"
|
|
|
|
provider = "github"
|
|
|
|
repo_path = "${local.github_full}"
|
|
|
|
}
|
|
|
|
}
|