Skip to content

Frontend Auth Integration, Route Completion & UI Consistency #104

Frontend Auth Integration, Route Completion & UI Consistency

Frontend Auth Integration, Route Completion & UI Consistency #104

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
services:
dynamodb-local:
image: amazon/dynamodb-local
ports:
- 8000:8000
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: |
npm ci
npm install @rollup/rollup-linux-x64-gnu --workspace=client --save-optional
# Client steps
- name: Lint client
working-directory: ./client
run: npm run lint
- name: Build client
working-directory: ./client
env:
VITE_API_URL: ${{ vars.VITE_API_URL }}
run: npm run build
- name: Test client
working-directory: ./client
run: npm test
- name: Wait for DynamoDB Local
run: |
echo "Waiting for DynamoDB Local..."
for i in {1..30}; do
if nc -z localhost 8000; then
echo "DynamoDB Local is ready"
exit 0
fi
sleep 1
done
echo "DynamoDB Local failed to start after 30s"
exit 1
- name: Create DynamoDB tables
working-directory: ./server
env:
DYNAMODB_ENDPOINT: ${{ vars.DYNAMODB_ENDPOINT }}
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: local
AWS_SECRET_ACCESS_KEY: local
run: npx tsx src/scripts/setup-tables.ts
# Server steps
- name: Lint server
working-directory: ./server
run: npm run lint
- name: Build server
working-directory: ./server
run: npm run build
- name: Test server
working-directory: ./server
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
NODE_ENV: test
BREVO_API_KEY: ${{ secrets.BREVO_API_KEY }}
DYNAMODB_ENDPOINT: ${{ vars.DYNAMODB_ENDPOINT }}
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: local
AWS_SECRET_ACCESS_KEY: local
run: npm test
# Deploy only on main branch
- name: Configure AWS credentials
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy frontend to S3
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
aws s3 sync ./client/dist s3://${{ vars.FRONTEND_BUCKET_NAME }}/ --delete --exact-timestamps
aws s3 cp ./client/dist/index.html s3://${{ vars.FRONTEND_BUCKET_NAME }}/index.html \
--content-type "text/html" \
--cache-control "no-cache, no-store, must-revalidate"
aws cloudfront create-invalidation \
--distribution-id ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"
- name: Bundle Lambda with esbuild
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
working-directory: ./server
run: |
npx esbuild src/lambda.ts \
--bundle \
--platform=node \
--target=node20 \
--outfile=dist/lambda.js \
--external:@aws-sdk/* \
--external:argon2
mkdir -p dist/node_modules/@phc
cp -r ../node_modules/argon2 dist/node_modules/argon2
cp -r ../node_modules/node-gyp-build dist/node_modules/node-gyp-build
cp -r ../node_modules/@phc/format dist/node_modules/@phc/format
cd dist && zip -r ../lambda.zip lambda.js node_modules/
- name: Deploy Lambda function code
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
working-directory: ./server
run: |
aws lambda update-function-code \
--function-name ${{ vars.LAMBDA_FUNCTION_NAME }} \
--zip-file fileb://lambda.zip \
--output text \
--query 'FunctionName'