Skip to content
Osinachi Chukwujama edited this page Jul 22, 2024 · 3 revisions

Deployment

Branching Strategy

To ensure smooth development and deployment processes, we follow a structured branching strategy:

Main Branches

  • dev: This branch is used for testing and the rest of the development activities.
  • staging: This branch is used for pre-production. It is a final testing ground before changes are pushed to production.
  • main: This branch is used for the production API. It contains the stable version of the code that is deployed to production.

Automated Deployments using GitHub Actions

The repository is set up to automatically deploy code when pull requests and merges happen on the dev, staging, and main branches. The workflows for these branches live in the .github/workflows directory as development.yml, staging.yml, and production.yml respectively.

The workflows define three steps:

  1. A build step for testing that the application can be built
  2. A test step to run the unit and integration tests defined in the application
  3. A deploy step that runs the application on a virtual machine

The deploy step requires four secrets of the target deployment virtual machine:

  1. SSH_HOST
  2. SSH_PORT
  3. SSH_USERNAME
  4. SSH_PASSWORD

These secrets must be defined as repository secrets under Actions. The workflow picks them up and uses them.

Steps for Deployment

1. Prepare for Deployment

Ensure all changes are tested locally before merging into the deployment branch.

2. Merge Changes to Deployment

  1. Create a pull request to merge your feature branch into the deployment branch.
  2. Review the changes and resolve any conflicts.
  3. Once approved, merge the pull request.

3. Testing in Deployment

  1. Deploy the deployment branch to the testing environment.
  2. Conduct thorough testing to ensure all features and fixes are working as expected.
  3. Log any issues and address them before proceeding.

4. Merge to Staging

  1. Once testing is complete, create a pull request to merge the deployment branch into the staging branch.
  2. Review the changes and resolve any conflicts.
  3. Once approved, merge the pull request.

5. Pre-Production Testing

  1. Deploy the staging branch to the pre-production environment.
  2. Conduct final testing to ensure stability and performance.
  3. Log any issues and address them before proceeding.

6. Merge to Production (main)

  1. Once pre-production testing is complete, create a pull request to merge the staging branch into the api branch.
  2. Review the changes and resolve any conflicts.
  3. Once approved, merge the pull request.

7. Production Deployment

  1. Once a merge happens on the main branch, the GitHub Actions workflows defined will run and auto deploy the app.
  2. Monitor the deployment to ensure everything is working smoothly.
  3. Address any issues that arise promptly.

By following this branching strategy, we ensure a controlled and systematic approach to deploying changes, reducing the risk of introducing issues into the production environment.