auto upload website to DO bucket
This commit is contained in:
parent
edc9b5e60a
commit
19887efd22
9
Makefile
9
Makefile
|
@ -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:
|
||||
|
|
|
@ -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}")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue