This document outlines the steps to set up the CI/CD pipeline for the MarkDock application using GitHub Actions.
- A GitHub repository
- An AWS account
- An IAM user with permissions to deploy to the S3 bucket and invalidate the CloudFront distribution
Inside your GitHub repository you will need to setup some secrets so that the workflow can know where to deploy the application.
The following secrets need to be set up in the repository settings:
AWS_ACCESS_KEY_ID
- The access key ID of the IAM userAWS_SECRET_ACCESS_KEY
- The secret access key of the IAM userAWS_REGION
- The region of the S3 bucketAWS_S3_BUCKET
- The name of the S3 bucketAWS_CLOUDFRONT_DISTRIBUTION_ID
- The ID of the CloudFront distribution
You can find these inside the AWS console. For creating the IAM user, you can use the IAM section of AWS and create a user with permission for creating and managing S3 buckets and CloudFront distributions.
The workflow is defined in the .github/workflows/deploy.yml
file. This file contains the steps that are executed when a push is made to the repository.
- The workflow is triggered on a push to the
main
branch. - The workflow checks out the code from the repository.
- The workflow installs the dependencies using
npm ci
. (npm ci is used to install the dependencies from thepackage-lock.json
file) - The workflow builds the application using
npm run build
. - The workflow deploys the application to the S3 bucket.
- The workflow invalidates the CloudFront distribution cache so that the changes are reflected immediately.
The workflow is defined in the .github/workflows/testing.yml
file. This file is used for running the tests on the application. Its used to ensure that the application is working as expected before deploying it.
- The workflow is triggered on a push to the
main
branch or a pull request to themain
branch. - The workflow checks out the code from the repository.
- The workflow installs the dependencies using
npm ci
. (npm ci is used to install the dependencies from thepackage-lock.json
file) - The workflow runs the tests using
npm run test
. - The workflow will pass if the tests are successful and fail if the tests fail.