docs
GitHub CI/CD Deployment
Deploy Staging

CI/CD Staging Deployment

We initially deployed to AWS using the cdk deploy CLI commands to get our infrastructure up and running. That was essential for the first deployment and setup.

Going forward, whenever we make changes to our code, we can just commit and push like usual. Thanks to our CI/CD pipeline, these updates will automatically trigger a deployment to our AWS infrastructure.

We've already configured the necessary secrets and variables in GitHub Actions, so our main.yml will take care of the rest—deploying everything for you as soon as you push your changes.

Deployment Trigger:

  • Staging: Deploys when you commit and push to the staging branch.

⚠️ Make sure that you have cloned the AWSLaunchGOAT-Backend repository and have your own GitHub repository prepared.

Step-by-Step

  1. Create a new branch staging from the main branch.

Create Permission Set

Ensure that you are working on staging branch.

Create Permission Set

  1. Let's update our code in src/app.ts by adding three exclamation marks: !!!

Create Permission Set

  1. Commit and sync changes (push). You can also do this via the command line.

Create Permission Set

  1. Go to GitHub Actions, and you will see that your workflow is now running.

Create Permission Set

  1. Click on the updated app.ts workflow, and you will notice that it is running the test step first.

Create Permission Set

⚠️ At the testing stage, docker-compose.test.yml is used in our CI/CD pipeline for staging. It loads Dockerfile.staging, replicating the staging environment to ensure that your changes are thoroughly tested before deployment.

  1. Apply the migration file to populate the tables and columns.

Create Permission Set

  1. After a few minutes, the entire workflow will fail because it encountered an error during the test stage.

Create Permission Set

  1. Let's update the test script. Go to tests/endpoints.test.ts and add three exclamation marks. Commit and push again. Go back to the GitHub Actions.

Create Permission Set

  1. Your test stage should now be successful, and the workflow will proceed to Deploy to Staging.

Create Permission Set

  1. Once completed, let's check our endpoint. Go to Load balancers from the AWS Management Console.

Create Permission Set

  1. Copy the DNS name and paste it into the browser.

Create Permission Set

  1. If you see three exclamation marks, then you're right on! (Make sure you are on http, not https)

Create Permission Set

  1. Lastly, since the migration file has been applied and the user table is populated, we can check if the /users endpoint is working.

Create Permission Set

404, Users not found is the message we want to see.