Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy Notice Board (Group2 Allen Marcos Addison Alex)

on:
push:
branches: [main, master]
paths:
- 'workshops/fullstack-aws/projects/Group2_Allen_Marcos_Addison_Alex/**'

defaults:
run:
working-directory: workshops/fullstack-aws/projects/Group2_Allen_Marcos_Addison_Alex

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Build and deploy backend
run: |
pip install -r backend/requirements.txt -t backend/_build -q
cp backend/lambda_function.py backend/_build/
cd backend/_build && zip -r ../lambda.zip . -x '*.pyc' && cd ../..
aws lambda update-function-code \
--function-name ${{ secrets.LAMBDA_FUNCTION_NAME }} \
--zip-file fileb://backend/lambda.zip

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Build frontend
working-directory: workshops/fullstack-aws/projects/Group2_Allen_Marcos_Addison_Alex/frontend
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
run: |
npm install
npm run build

- name: Deploy frontend to S3
run: |
aws s3 sync frontend/dist/ s3://${{ secrets.S3_BUCKET }}/ --delete

- name: Invalidate CloudFront cache
env:
CF_DISTRIBUTION_ID: ${{ secrets.CF_DISTRIBUTION_ID }}
run: |
if [ -n "$CF_DISTRIBUTION_ID" ]; then
aws cloudfront create-invalidation \
--distribution-id "$CF_DISTRIBUTION_ID" \
--paths "/*"
else
echo "CF_DISTRIBUTION_ID not set, skipping invalidation"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules/
dist/
*.zip
backend/_build/
.terraform/
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.backup
terraform.tfvars
.env
__pycache__/
venv/

Loading