forked from public/stack
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: \
|
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:
|
||||||
|
|
|
@ -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}")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue