auto upload website to DO bucket

This commit is contained in:
Lance Vick 2023-03-16 21:14:39 -07:00
parent edc9b5e60a
commit 19887efd22
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
2 changed files with 27 additions and 27 deletions

View File

@ -15,7 +15,7 @@ KEYS := \
default: \
toolchain \
$(patsubst %,$(KEY_DIR)/%.asc,$(KEYS)) \
$(OUT_DIR)/.well-known/openpgpkey \
$(OUT_DIR)/website/.well-known/openpgpkey \
apply
.PHONY:
@ -29,10 +29,10 @@ credentials: \
$(KEY_DIR)/%.asc:
$(call fetch_pgp_key,$(basename $(notdir $@)))
$(OUT_DIR)/.well-known/openpgpkey:
$(OUT_DIR)/website/.well-known/openpgpkey:
$(call toolchain," \
sq wkd \
generate $(OUT_DIR) distrust.co \
generate $(OUT_DIR)/website distrust.co \
<(cat $(patsubst %,$(KEY_DIR)/%.asc,$(KEYS))) \
")
@ -71,6 +71,9 @@ apply: \
$(OUT_DIR)/terraform \
infra/main/.terraform
env -C infra/main $(TERRAFORM) apply \
-var environment=$(ENVIRONMENT) \
-var namespace=$(ENVIRONMENT) \
-var region=$(REGION) \
-var-file ../../$<
$(CACHE_DIR)/secrets:

View File

@ -1,28 +1,25 @@
# Create local directories as scratch space
resource "local_file" "openpgpkey" {
filename = ".well-known/openpgpkey/policy"
content = ""
}
resource "local_file" "hu" {
filename = ".well-known/openpgpkey/hu/.keep"
content = ""
depends_on = [local_file.openpgpkey]
}
resource "local_file" "static_dir" {
filename = "static/.keep"
content = ""
variable "environment" {}
variable "namespace" {}
variable "region" {}
variable "out_dir" {
type = string
default = "/home/build/out"
}
# Create local files as scratch space
resource "local_file" "policy" {
filename = ".well-known/openpgpkey/policy"
content = ""
depends_on = [local_file.openpgpkey]
resource "random_id" "suffix" {
byte_length = 8
}
# Upload files to Digital Ocean
## The Digital Ocean Spaces API is compatible with Amazon S3
# resource "local_exec" "s3cmd" {
# command = "s3cmd put --recursive --acl-public --guess-mime-type --verbose static/ s3://static-site/"
# depends_on = [local_file.index_html, local_file.static_dir]
# }
resource "digitalocean_spaces_bucket" "website" {
name = "website-${random_id.suffix.hex}"
region = var.region
}
resource "digitalocean_spaces_bucket_object" "website" {
for_each = fileset("${var.out_dir}/website", "*")
region = var.region
bucket = digitalocean_spaces_bucket.website.name
source = "${var.out_dir}/website/${each.value}"
key = each.value
etag = filemd5("${var.out_dir}/website/${each.value}")
}