-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update personal website frontend, add backend and setup deploy workflow
- Loading branch information
1 parent
deb40b9
commit 64ec8e8
Showing
86 changed files
with
1,120 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Deploy on server | ||
on: | ||
workflow_run: | ||
workflows: [ backend-deploy ] | ||
branches: [ main ] | ||
types: | ||
- completed | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- run: echo 'The triggering workflow passed' | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
- name: Install Dependencies | ||
run: pip install -r requirements.txt -t ./package --platform manylinux2014_x86_64 --only-binary=:all | ||
- name: Archive the lambda function code and dependencies | ||
run: zip -r ../deployment_package.zip package | ||
- name: Push code to lambda | ||
run: aws lambda update-function-code --function-name ${{ env.AWS_LAMBDA_FUNCTION_ARN }} --zip-file fileb://deployment_package.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Python testing and linting | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
AWS_REGION: us-east-1 | ||
|
||
jobs: | ||
lint-and-test: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./backend/contact_form_lambda | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout source code | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
- run: pip install -r requirements.txt | ||
- uses: chartboost/ruff-action@v1 | ||
- name: Run Tests | ||
run: python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: check-json | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: detect-aws-credentials | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.6.2 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Contact Form | ||
|
||
## Testing | ||
With Httpie: https://httpie.io/ | ||
```bash | ||
http POST https://lp2rry5bz9.execute-api.us-east-1.amazonaws.com/ name=Dustin email=dustin@alandzes.com body=Hey | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import json | ||
import os | ||
from typing import TypedDict, Any | ||
|
||
import boto3 | ||
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
from mypy_boto3_sns.service_resource import SNSServiceResource | ||
from pydantic import BaseModel | ||
|
||
|
||
# APIGatewayProxyEvent | ||
class ContactFormSubmission(BaseModel): | ||
name: str | ||
email: str | ||
body: str | ||
|
||
|
||
class Event(TypedDict): | ||
name: str | ||
email: str | ||
body: str | ||
|
||
|
||
class Response(TypedDict): | ||
statusCode: int | ||
success: bool | ||
|
||
|
||
def handler(event: dict[str, Any], context: LambdaContext) -> Response: | ||
"""Accepts input from a contact form and publishes it to an SNS topic. | ||
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sns.html | ||
https://docs.aws.amazon.com/sns/ | ||
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic | ||
see: main.tf for sns topic details | ||
""" | ||
event = APIGatewayProxyEvent(event) | ||
sns: SNSServiceResource = boto3.resource("sns", region_name="us-east-1") | ||
sns_topic_arn: str = os.environ["SNS_TOPIC_ARN"] | ||
topic: sns.Topic = sns.Topic(sns_topic_arn) | ||
body = json.loads(event.body) | ||
topic.publish( | ||
Message=f""" | ||
Name: {body['name']} | ||
Email: {body['email']} | ||
Body: {body['body']} | ||
""" | ||
) | ||
|
||
# if everything goes well, return a 200 status and success: true | ||
return { | ||
"statusCode": 200, | ||
"success": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import json | ||
import os | ||
from unittest import mock | ||
|
||
import boto3 | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
from moto import mock_aws | ||
|
||
from main import handler | ||
|
||
from moto.core import DEFAULT_ACCOUNT_ID | ||
from moto.sns import sns_backends | ||
|
||
|
||
@mock_aws | ||
def test_happy_path(): | ||
"""Tests the happy path where we successfully publish to the topic.""" | ||
sns = boto3.resource("sns", region_name="us-east-1") | ||
# We need to create the bucket since this is all in Moto's 'virtual' AWS account | ||
topic = sns.create_topic(Name="TestTopic") | ||
|
||
sns_backend = sns_backends[DEFAULT_ACCOUNT_ID][ | ||
"us-east-1" | ||
] # Use the appropriate account/region | ||
all_send_notifications = sns_backend.topics[topic.arn].sent_notifications | ||
assert len(all_send_notifications) == 0 | ||
|
||
sample_event = { | ||
"body": '{"name": "Dustin", "email": "dustin@alandzes.com", "body": "Hey"}' | ||
} | ||
with mock.patch.dict(os.environ, {"SNS_TOPIC_ARN": topic.arn}): | ||
actual = handler(sample_event, LambdaContext()) | ||
|
||
expected = { | ||
"statusCode": 200, | ||
"success": True, | ||
} | ||
assert actual == expected | ||
assert len(all_send_notifications) == 1 | ||
|
||
body = json.loads(sample_event["body"]) | ||
assert ( | ||
all_send_notifications[0][1] | ||
== f""" | ||
Name: {body['name']} | ||
Email: {body['email']} | ||
Body: {body['body']} | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
annotated-types==0.7.0 | ||
aws-lambda-powertools==2.43.1 | ||
boto3==1.35.5 | ||
boto3-stubs==1.35.5 | ||
botocore==1.35.5 | ||
botocore-stubs==1.35.5 | ||
certifi==2024.7.4 | ||
cffi==1.17.0 | ||
charset-normalizer==3.3.2 | ||
cryptography==43.0.0 | ||
idna==3.8 | ||
iniconfig==2.0.0 | ||
Jinja2==3.1.4 | ||
jmespath==1.0.1 | ||
MarkupSafe==2.1.5 | ||
moto==5.0.13 | ||
mypy-boto3-cloudformation==1.35.0 | ||
mypy-boto3-dynamodb==1.35.0 | ||
mypy-boto3-ec2==1.35.3 | ||
mypy-boto3-lambda==1.35.3 | ||
mypy-boto3-rds==1.35.0 | ||
mypy-boto3-s3==1.35.2 | ||
mypy-boto3-sns==1.35.0 | ||
mypy-boto3-sqs==1.35.0 | ||
packaging==24.1 | ||
pluggy==1.5.0 | ||
pycparser==2.22 | ||
pydantic==2.8.2 | ||
pydantic_core==2.20.1 | ||
pytest==8.3.2 | ||
python-dateutil==2.9.0.post0 | ||
PyYAML==6.0.2 | ||
requests==2.32.3 | ||
responses==0.25.3 | ||
s3transfer==0.10.2 | ||
six==1.16.0 | ||
types-awscrt==0.21.2 | ||
types-s3transfer==0.10.1 | ||
typing_extensions==4.12.2 | ||
urllib3==2.2.2 | ||
Werkzeug==3.0.4 | ||
xmltodict==0.13.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-271 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Bold.ttf
Binary file not shown.
Binary file removed
BIN
-273 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-BoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-273 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-ExtraBold.ttf
Binary file not shown.
Binary file removed
BIN
-275 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-ExtraBoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-268 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-ExtraLight.ttf
Binary file not shown.
Binary file removed
BIN
-268 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-ExtraLightItalic.ttf
Binary file not shown.
Binary file removed
BIN
-270 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Italic.ttf
Binary file not shown.
Binary file removed
BIN
-270 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Light.ttf
Binary file not shown.
Binary file removed
BIN
-271 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-LightItalic.ttf
Binary file not shown.
Binary file removed
BIN
-267 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Medium.ttf
Binary file not shown.
Binary file removed
BIN
-270 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-MediumItalic.ttf
Binary file not shown.
Binary file removed
BIN
-267 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Regular.ttf
Binary file not shown.
Binary file removed
BIN
-271 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-SemiBold.ttf
Binary file not shown.
Binary file removed
BIN
-273 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-SemiBoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-264 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Thin.ttf
Binary file not shown.
Binary file removed
BIN
-267 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-ThinItalic.ttf
Binary file not shown.
Binary file removed
BIN
-206 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Bold.ttf
Binary file not shown.
Binary file removed
BIN
-209 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-BoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-208 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-ExtraBold.ttf
Binary file not shown.
Binary file removed
BIN
-210 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-ExtraBoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-204 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-ExtraLight.ttf
Binary file not shown.
Binary file removed
BIN
-205 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-ExtraLightItalic.ttf
Binary file not shown.
Binary file removed
BIN
-207 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Italic.ttf
Binary file not shown.
Binary file removed
BIN
-206 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Light.ttf
Binary file not shown.
Binary file removed
BIN
-207 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-LightItalic.ttf
Binary file not shown.
Binary file removed
BIN
-203 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Medium.ttf
Binary file not shown.
Binary file removed
BIN
-207 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-MediumItalic.ttf
Binary file not shown.
Binary file removed
BIN
-204 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Regular.ttf
Binary file not shown.
Binary file removed
BIN
-205 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-SemiBold.ttf
Binary file not shown.
Binary file removed
BIN
-209 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-SemiBoldItalic.ttf
Binary file not shown.
Binary file removed
BIN
-201 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-Thin.ttf
Binary file not shown.
Binary file removed
BIN
-204 KB
frontend/public/JetBrainsMono-2.304/fonts/ttf/JetBrainsMonoNL-ThinItalic.ttf
Binary file not shown.
Binary file removed
BIN
-302 KB
frontend/public/JetBrainsMono-2.304/fonts/variable/JetBrainsMono-Italic[wght].ttf
Binary file not shown.
Binary file removed
BIN
-296 KB
frontend/public/JetBrainsMono-2.304/fonts/variable/JetBrainsMono[wght].ttf
Binary file not shown.
Binary file removed
BIN
-92.4 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Bold.woff2
Binary file not shown.
Binary file removed
BIN
-95.9 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-BoldItalic.woff2
Binary file not shown.
Binary file removed
BIN
-91.5 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-ExtraBold.woff2
Binary file not shown.
Binary file removed
BIN
-94.6 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-ExtraBoldItalic.woff2
Binary file not shown.
Binary file removed
BIN
-90.5 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-ExtraLight.woff2
Binary file not shown.
Binary file removed
BIN
-93.6 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-ExtraLightItalic.woff2
Binary file not shown.
Binary file removed
BIN
-93.6 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Italic.woff2
Binary file not shown.
Binary file removed
BIN
-91.7 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Light.woff2
Binary file not shown.
Binary file removed
BIN
-95 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-LightItalic.woff2
Binary file not shown.
Binary file removed
BIN
-91.6 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Medium.woff2
Binary file not shown.
Binary file removed
BIN
-95.5 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-MediumItalic.woff2
Binary file not shown.
Binary file removed
BIN
-90 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Regular.woff2
Binary file not shown.
Binary file removed
BIN
-92.3 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-SemiBold.woff2
Binary file not shown.
Binary file removed
BIN
-95.8 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-SemiBoldItalic.woff2
Binary file not shown.
Binary file removed
BIN
-88.5 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Thin.woff2
Binary file not shown.
Binary file removed
BIN
-92.1 KB
frontend/public/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-ThinItalic.woff2
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.