CI/CD Workflow

The CI/CD workflow is implemented using GitHub Actions to automate builds, tests, and deployments.

Workflow Triggers

The workflow is triggered by the following events:

Workflow Steps

The workflow consists of the following steps:

  1. Checkout: The actions/checkout@v3 action checks out the repository code. Source: .github/workflows/ci.yml
  2. Build: The actions/setup-node@v3 action sets up Node.js, and then the npm ci command installs dependencies. Source: .github/workflows/ci.yml
  3. Test: The npm test command runs the unit tests. Source: .github/workflows/ci.yml
  4. Deploy: The actions/upload-artifact@v3 action uploads the built application to GitHub Packages. Source: .github/workflows/ci.yml

Workflow Options

The ci.yml file provides a number of options to customize the workflow. These options include:

Examples

Here are some examples of how to customize the CI/CD workflow:

  • Change the Node.js version:
jobs:
            build:
              runs-on: ubuntu-latest
              steps:
                - uses: actions/checkout@v3
                - uses: actions/setup-node@v3
                  with:
                    node-version: 18
                - run: npm ci
          
  • Run different tests:
jobs:
            build:
              runs-on: ubuntu-latest
              steps:
                - uses: actions/checkout@v3
                - uses: actions/setup-node@v3
                - run: npm test -- --coverage
          
  • Deploy to a different environment:
jobs:
            build:
              runs-on: ubuntu-latest
              steps:
                - uses: actions/checkout@v3
                - uses: actions/setup-node@v3
                - run: npm ci
                - run: npm test
                - uses: actions/upload-artifact@v3
                  with:
                    name: app
                    path: dist
                    if: ${{ success() }}
            deploy:
              runs-on: ubuntu-latest
              needs: build
              steps:
                - uses: actions/checkout@v3
                - uses: actions/download-artifact@v3
                  with:
                    name: app
                - run: echo "Deploying to staging environment"