Skip to content

format code

format code #263

name: Backend Pipeline
# Workflow triggers
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: 0 0 * * MON # Schedule pipeline to run monday midnight after sunday ends
workflow_dispatch: # Enable manual runs of workflow
# Workflow stages
jobs:
# Perform Lint Checks
lint:
name: Lint Checks
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Run lint script
run: pnpm run lint
# Run Unit Tests
test:
name: Unit Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
- name: Clear jest cache
run: pnpm jest --clearCache
- name: Run unit tests with jest
run: pnpm run test
# Build Application
build:
name: Build Application
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install pnpm
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Compile TypeScript into JavaScript
run: pnpm run build
# Deploy Application to Development Environment
deploy-dev:
name: Deploy to Development Environment
needs: [lint, test, build] # lint, test, and build must pass before deployment
if: github.event_name == 'schedule' || github.event_name == 'push' # only deploy on push and weekly CRON job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME_DEV }}
password: ${{ secrets.DOCKER_PASSWORD_DEV }}
- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile.dev
push: true
tags: fitnessehealthapp/backend:development
platforms: linux/amd64
- name: Deploy Docker Image to Render
run: |
curl -X POST ${{ secrets.RENDER_DEPLOY_HOOK_DEV }}