Skip to content

Commit c461d42

Browse files
committed
chore: ui deployment
1 parent b0bffbf commit c461d42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+140
-7
lines changed

.github/workflows/api-deploy.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ permissions:
1111

1212
jobs:
1313
build-deploy:
14+
environment: dev
1415
name: Build & Deploy 📦
1516
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./api
20+
1621

1722
steps:
1823
- uses: actions/checkout@v4
@@ -29,10 +34,7 @@ jobs:
2934
- name: Install dependencies
3035
run: pip install cargo-lambda
3136
- name: Build
32-
run: |
33-
cd api
34-
cargo lambda build --release --output-format zip
37+
run: cargo lambda build --release --output-format zip
3538

3639
- name: Upload to Lambda
37-
run: |
38-
aws lambda update-function-code --function-name kb2-lambda-function-dev --zip-file fileb://api/target/lambda/api/bootstrap.zip
40+
run: aws lambda update-function-code --function-name kb2-lambda-function-dev --zip-file fileb://api/target/lambda/api/bootstrap.zip

.github/workflows/ui-deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: UI S3 Deploy 📦🪣
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- ui/**
8+
- ui-deploy.yml
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-deploy:
14+
environment: dev
15+
name: Build & Deploy 🪣
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./ui
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 22
28+
29+
- name: Install npm requirements
30+
run: npm install
31+
32+
- name: Build npm
33+
run: npm run build
34+
env:
35+
VITE_KB_API_URL: ${{ vars.VITE_KB_API_URL }}
36+
VITE_DISCORD_CLIENT_ID: ${{ vars.VITE_DISCORD_CLIENT_ID }}
37+
VITE_GOOGLE_CLIENT_ID: ${{ vars.VITE_GOOGLE_CLIENT_ID }}
38+
VITE_MICROSOFT_CLIENT_ID: ${{ vars.VITE_MICROSOFT_CLIENT_ID }}
39+
40+
- name: Setup AWS CLI
41+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
42+
with:
43+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
44+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
45+
aws-region: eu-west-2
46+
47+
- name: Deploy Modified Files
48+
run: aws s3 sync --delete ./dist s3://${{vars.AWS_S3_BUCKET}}

api/Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/modules/api/api-gateway/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ resource "aws_api_gateway_stage" "default" {
7878
resource "aws_api_gateway_base_path_mapping" "default" {
7979
api_id = aws_api_gateway_rest_api.default.id
8080
stage_name = aws_api_gateway_stage.default.stage_name
81-
domain_name = "api.${var.deployment_env}.${var.root_domain_name}" # TODO: Create Domain Name Resource
81+
domain_name = "api.${var.ui_hostname}" # TODO: Create Domain Name Resource
8282
}
8383

8484
resource "aws_api_gateway_usage_plan" "default" {

infra/modules/api/api-gateway/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ variable "lambda_function_name" {
1212

1313
variable "root_domain_name" {
1414
type = string
15+
}
16+
17+
variable "ui_hostname" {
18+
type = string
19+
description = "The hostname for the UI, e.g., 'koalabot.uk'. This is used to set up the API Gateway custom domain name."
1520
}

infra/modules/data/s3/main.tf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
resource "aws_s3_bucket" "public_ui" {
2+
bucket = "${var.deployment_env}.koalabot.uk"
3+
4+
tags = {
5+
Name = var.deployment_env == "prod" ? "koalabot.uk" : "${var.deployment_env}.koalabot.uk",
6+
Environment = var.deployment_env
7+
}
8+
}
9+
10+
resource "aws_s3_bucket_policy" "bucket_policy" {
11+
bucket = aws_s3_bucket.public_ui.id
12+
policy = jsonencode({
13+
Version = "2012-10-17",
14+
Statement = [
15+
{
16+
"Sid": "PublicReadGetObject",
17+
"Effect": "Allow",
18+
"Principal": "*",
19+
"Action": "s3:GetObject",
20+
"Resource": "arn:aws:s3:::${aws_s3_bucket.public_ui.bucket}/*",
21+
"Condition": {
22+
"IpAddress": {
23+
"aws:SourceIp": [
24+
"173.245.48.0/20",
25+
"103.21.244.0/22",
26+
"103.22.200.0/22",
27+
"103.31.4.0/22",
28+
"141.101.64.0/18",
29+
"108.162.192.0/18",
30+
"190.93.240.0/20",
31+
"188.114.96.0/20",
32+
"197.234.240.0/22",
33+
"198.41.128.0/17",
34+
"162.158.0.0/15",
35+
"104.16.0.0/13",
36+
"104.24.0.0/14",
37+
"172.64.0.0/13",
38+
"131.0.72.0/22"
39+
]
40+
}
41+
}
42+
}
43+
]
44+
})
45+
}
46+
47+
resource "aws_s3_bucket_website_configuration" "default" {
48+
bucket = aws_s3_bucket.public_ui.id
49+
50+
index_document {
51+
suffix = "index.html"
52+
}
53+
54+
error_document {
55+
key = "error.html"
56+
}
57+
}
58+
59+
output "website_url" {
60+
value = aws_s3_bucket.public_ui.website_endpoint
61+
}

infra/modules/data/s3/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "ui_hostname" {
2+
value = aws_s3_bucket.public_ui.bucket
3+
description = "The hostname for the UI, e.g., 'koalabot.uk'."
4+
}

infra/modules/data/s3/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "deployment_env" {
2+
type = string
3+
}
File renamed without changes.

0 commit comments

Comments
 (0)