Our project utilizes two primary workflows: the CI Workflow and the Terraform, Build, and Deploy Workflow. Both workflows are integral components of our development process, enabling us to maintain a high-quality, up-to-date, and secure codebase.
Workflow file: .github/workflows/ci.yml
The CI Workflow is triggered on pull requests to the main
or develop
branches. This workflow is primarily designed to ensure the integrity of the codebase by building the application and potentially running tests whenever changes are proposed via pull requests.
The CI workflow follows these steps:
- Checks out the repository.
- Sets up the desired version of Node.js.
- Installs the project dependencies with
npm ci
. This command is similar tonpm install
, but it's designed to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies. It can significantly reduce install time by skipping certain user-oriented features. It also ensures thatpackage-lock.json
is respected. - Sets up the environment based on the target branch (using
main
ordevelop
environment secrets). - Builds the application with
npm run build
. - (When tests are added) Runs the tests with
npm test
.
This CI workflow helps ensure that any proposed changes to the develop
or main
branches do not break the application build process.
Workflow file: .github/workflows/cd.yml
The Terraform, Build, and Deploy Workflow handles the continuous deployment of the application. This workflow is triggered when changes are pushed to the develop
branch or can be manually triggered via workflow_dispatch
for a specific environment.
This workflow consists of two jobs:
- Terraform job: This sets up the necessary infrastructure using Terraform and Terragrunt.
- Build and Deploy job: This handles building and deploying the application.
This workflow ensures that our application is consistently deployed and up-to-date with the latest changes in the codebase.
We follow a slightly modified version of the GitHub Flow. Here are the key principles:
- Ongoing development should be done in feature branches off
develop
. - Once the feature is completed, open a pull request to merge these changes into
develop
. The changes will then be deployed to the development environment. - After reviewing and testing the changes in the development environment, merge
develop
intomain
using a pull request. The changes will then be deployed into the production environment. - Anything in the
main
branch is always deployable to the production environment.
Following these principles helps ensure that our codebase remains clean, and all changes are reviewed and tested before being deployed.
Both workflows utilize certain environment variables and secrets for tasks such as accessing AWS resources and setting up application configuration. Ensure these are correctly configured in your GitHub repository settings.