diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 2c5c483..c6dd7ae 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -54,8 +54,7 @@ jobs: - name: Deploy infrastructure run: | - bash bin/deploy.sh - bash bin/seed.sh + ./bin/deploy.sh - name: Run Integration Tests env: diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index e3a888d..c26af8b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -27,8 +27,7 @@ jobs: extension-auto-install: 'localstack-extension-mailhog' preview-cmd: | pip install awscli awscli-local - bash bin/deploy.sh - bash bin/seed.sh + ./bin/deploy.sh distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id'); echo LS_PREVIEW_URL=$AWS_ENDPOINT_URL/cloudfront/$distributionId/ >> $GITHUB_ENV; env: diff --git a/README.md b/README.md index 3d71e56..3df75f0 100644 --- a/README.md +++ b/README.md @@ -59,15 +59,7 @@ CloudFront URL: https://1e372b81.cloudfront.localhost.localstack.cloud API Gateway Endpoint: http://localhost:4566/restapis/4xu5emxibf/test/_user_request_ ``` -Navigate to the CloudFront URL to check out the app. - -To seed some quiz data and user data, run the following command: - -```bash -bash bin/seed.sh -``` - -The above command will add three quizzes to the app. +Navigate to the CloudFront URL to check out the app. The script would also seed some quiz data and user data to make local testing easier. ## Local Testing diff --git a/bin/deploy.sh b/bin/deploy.sh index 89b7fa7..a2ae0d1 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -286,8 +286,17 @@ log "State Machine created." # Deploy Frontend log "Deploying frontend..." pushd frontend >/dev/null -npm install >/dev/null +if [ -d "node_modules" ]; then + log "node_modules directory already present. Skipping npm install." +else + log "node_modules directory not found. Installing dependencies..." + npm install >/dev/null +fi + +log "Building the project..." npm run build >/dev/null + +log "Uploading frontend build to S3..." awslocal s3 mb s3://webapp >/dev/null awslocal s3 sync --delete ./build s3://webapp >/dev/null awslocal s3 website s3://webapp --index-document index.html --error-document index.html >/dev/null @@ -366,6 +375,10 @@ log "Cleaning up temporary files..." rm *.zip log "Cleanup completed." +log "Starting seed process..." +./bin/seed.sh +log "Seed process completed successfully." + # Final Output log "Deployment completed successfully." echo diff --git a/bin/ephemeral.sh b/bin/ephemeral.sh index 9793816..54b613a 100644 --- a/bin/ephemeral.sh +++ b/bin/ephemeral.sh @@ -40,7 +40,6 @@ export ENDPOINT_URL="$ENDPOINT_URL" echo "Deploying resources..." bash bin/deploy.sh > /dev/null 2>&1 -bash bin/seed.sh > /dev/null 2>&1 echo "Deployment completed." DISTRIBUTION_ID=$(awslocal cloudfront list-distributions --endpoint-url="$ENDPOINT_URL" | jq -r '.DistributionList.Items[0].Id') diff --git a/bin/seed.sh b/bin/seed.sh old mode 100644 new mode 100755 diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..47a10ca --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +awslocal lambda update-function-code --function-name ScoringFunction --s3-bucket hot-reload --s3-key "$(pwd)/lambdas/scoring" + +awslocal lambda update-function-code --function-name ScoringFunction --code S3Bucket="hot-reload",S3Key="$(pwd)/lambdas/scoring"