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:
- push: The workflow runs every time code is pushed to the
main
branch. Source:.github/workflows/ci.yml
- pull_request: The workflow runs every time a pull request is created or updated. Source:
.github/workflows/ci.yml
Workflow Steps
The workflow consists of the following steps:
- Checkout: The
actions/checkout@v3
action checks out the repository code. Source:.github/workflows/ci.yml
- Build: The
actions/setup-node@v3
action sets up Node.js, and then thenpm ci
command installs dependencies. Source:.github/workflows/ci.yml
- Test: The
npm test
command runs the unit tests. Source:.github/workflows/ci.yml
- 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:
- Build: The build step can be customized to use different Node.js versions or to install different dependencies. Source:
.github/workflows/ci.yml
- Test: The test step can be customized to run different tests or to use different test frameworks. Source:
.github/workflows/ci.yml
- Deploy: The deploy step can be customized to deploy the application to different environments or to use different deployment methods. Source:
.github/workflows/ci.yml
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"