Skip to content

Commit

Permalink
deploy infrastructure and perform seeding in one step
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshCasper committed Nov 25, 2024
1 parent 4024049 commit 65485a4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion bin/ephemeral.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Empty file modified bin/seed.sh
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 65485a4

Please sign in to comment.