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

View File

@ -1,28 +1,25 @@
# Create local directories as scratch space variable "environment" {}
resource "local_file" "openpgpkey" { variable "namespace" {}
filename = ".well-known/openpgpkey/policy" variable "region" {}
content = "" variable "out_dir" {
} type = string
resource "local_file" "hu" { default = "/home/build/out"
filename = ".well-known/openpgpkey/hu/.keep"
content = ""
depends_on = [local_file.openpgpkey]
}
resource "local_file" "static_dir" {
filename = "static/.keep"
content = ""
} }
# Create local files as scratch space resource "random_id" "suffix" {
resource "local_file" "policy" { byte_length = 8
filename = ".well-known/openpgpkey/policy"
content = ""
depends_on = [local_file.openpgpkey]
} }
# Upload files to Digital Ocean resource "digitalocean_spaces_bucket" "website" {
## The Digital Ocean Spaces API is compatible with Amazon S3 name = "website-${random_id.suffix.hex}"
# resource "local_exec" "s3cmd" { region = var.region
# 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_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}")
}