~repos /website
git clone https://pyrossh.dev/repos/website.git
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
4af16775
—
pyrossh 1 month ago
update zip
- deploy.sh +2 -2
- infra/main.tf +15 -6
- src/pages/repos/[...slug]/index.astro +2 -2
deploy.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
rm -rf dist
|
|
2
2
|
bun run build
|
|
3
3
|
aws s3 sync --delete ./dist/ s3://pyrossh-website
|
|
4
|
+
cd infra && terraform validate && terraform plan && terraform apply -auto-approve
|
|
4
|
-
aws cloudfront create-invalidation --distribution-id E2KFT51L97LWA1 --paths "/*" --no-cli-pager
|
|
5
|
+
aws cloudfront create-invalidation --distribution-id E2KFT51L97LWA1 --paths "/*" --no-cli-pager
|
|
5
|
-
cd infra && terraform validate && terraform plan && terraform apply -auto-approve
|
infra/main.tf
CHANGED
|
@@ -28,6 +28,15 @@ provider "aws" {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
# locals {
|
|
32
|
+
# # Read the content of the JSON file
|
|
33
|
+
# json_content = file("${path.module}/data.json")
|
|
34
|
+
|
|
35
|
+
# # Decode the JSON string into a Terraform object
|
|
36
|
+
# config = jsondecode(local.json_content)
|
|
37
|
+
# }
|
|
38
|
+
|
|
39
|
+
|
|
31
40
|
resource "aws_route53_zone" "main" {
|
|
32
41
|
name = "pyrossh.dev"
|
|
33
42
|
}
|
|
@@ -119,8 +128,8 @@ resource "aws_acm_certificate" "domain_ssl_certificate" {
|
|
|
119
128
|
provider = aws.useast
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
resource "aws_cloudfront_function" "
|
|
131
|
+
resource "aws_cloudfront_function" "html_redirector" {
|
|
123
|
-
name = "
|
|
132
|
+
name = "html_redirector"
|
|
124
133
|
runtime = "cloudfront-js-2.0"
|
|
125
134
|
publish = true
|
|
126
135
|
code = <<CODE
|
|
@@ -148,7 +157,7 @@ resource "aws_cloudfront_function" "zip_redirector" {
|
|
|
148
157
|
const uri = request.uri;
|
|
149
158
|
|
|
150
159
|
if (uri.endsWith('.zip')) {
|
|
151
|
-
request.uri = "/" + request.uri.replace("/
|
|
160
|
+
request.uri = "/" + request.uri.replace("/repos/", "").replace(".zip", "") + "/refs/heads/master/repo.zip"
|
|
152
161
|
return request;
|
|
153
162
|
}
|
|
154
163
|
return {
|
|
@@ -230,7 +239,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
|
|
230
239
|
}
|
|
231
240
|
|
|
232
241
|
ordered_cache_behavior {
|
|
233
|
-
path_pattern = "/
|
|
242
|
+
path_pattern = "/repos/*.zip"
|
|
234
243
|
allowed_methods = ["GET", "HEAD"]
|
|
235
244
|
cached_methods = ["GET", "HEAD"]
|
|
236
245
|
target_origin_id = aws_s3_bucket.repos_bucket.bucket_regional_domain_name
|
|
@@ -270,7 +279,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
|
|
270
279
|
max_ttl = 86400
|
|
271
280
|
function_association {
|
|
272
281
|
event_type = "viewer-request"
|
|
273
|
-
function_arn = aws_cloudfront_function.
|
|
282
|
+
function_arn = aws_cloudfront_function.html_redirector.arn
|
|
274
283
|
}
|
|
275
284
|
}
|
|
276
285
|
|
|
@@ -290,7 +299,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
|
|
290
299
|
max_ttl = 86400
|
|
291
300
|
function_association {
|
|
292
301
|
event_type = "viewer-request"
|
|
293
|
-
function_arn = aws_cloudfront_function.
|
|
302
|
+
function_arn = aws_cloudfront_function.html_redirector.arn
|
|
294
303
|
}
|
|
295
304
|
}
|
|
296
305
|
|
src/pages/repos/[...slug]/index.astro
CHANGED
|
@@ -39,8 +39,8 @@ const { Content } = await render(Astro.props);
|
|
|
39
39
|
</h3>
|
|
40
40
|
<h3>
|
|
41
41
|
wget
|
|
42
|
-
<a href={`https://pyrossh.dev/
|
|
42
|
+
<a href={`https://pyrossh.dev/repos/${title}.zip`}>
|
|
43
|
-
https://pyrossh.dev/
|
|
43
|
+
https://pyrossh.dev/repos/{title}.zip
|
|
44
44
|
<!-- https://pyrossh-repos.s3.ap-south-1.amazonaws.com/rp2350/refs/heads/master/repo.zip -->
|
|
45
45
|
</a>
|
|
46
46
|
</h3>
|