-
Notifications
You must be signed in to change notification settings - Fork 50
6. Deployments
To ensure smooth development and deployment processes, we follow a structured branching strategy:
- 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.
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:
- A build step for testing that the application can be built
- A test step to run the unit and integration tests defined in the application
- A deploy step that runs the application on a virtual machine
The deploy step requires four secrets of the target deployment virtual machine:
- SSH_HOST
- SSH_PORT
- SSH_USERNAME
- SSH_PASSWORD
These secrets must be defined as repository secrets under Actions. The workflow picks them up and uses them.
Ensure all changes are tested locally before merging into the deployment
branch.
- Create a pull request to merge your feature branch into the
deployment
branch. - Review the changes and resolve any conflicts.
- Once approved, merge the pull request.
- Deploy the
deployment
branch to the testing environment. - Conduct thorough testing to ensure all features and fixes are working as expected.
- Log any issues and address them before proceeding.
- Once testing is complete, create a pull request to merge the
deployment
branch into thestaging
branch. - Review the changes and resolve any conflicts.
- Once approved, merge the pull request.
- Deploy the
staging
branch to the pre-production environment. - Conduct final testing to ensure stability and performance.
- Log any issues and address them before proceeding.
- Once pre-production testing is complete, create a pull request to merge the
staging
branch into theapi
branch. - Review the changes and resolve any conflicts.
- Once approved, merge the pull request.
- Once a merge happens on the main branch, the GitHub Actions workflows defined will run and auto deploy the app.
- Monitor the deployment to ensure everything is working smoothly.
- 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.