node.js.yml
1 # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 name: Node.js CI 4 on: 5 push: 6 branches: [ main ] 7 tags: 8 - v* 9 pull_request: 10 branches: [ main ] 11 env: 12 IMAGE_NAME: creature-api-boilerplate 13 jobs: 14 build: 15 runs-on: ubuntu-22.04 16 services: 17 # Label used to access the service container 18 postgres: 19 ports: 20 - 5432:5432 21 # Docker Hub image 22 image: postgres:15-alpine 23 # Provide the password for postgres 24 env: 25 POSTGRES_PASSWORD: postgres 26 POSTGRES_DB: creature_api_boilerplate 27 # Set health checks to wait until postgres has started 28 options: >- 29 --health-cmd pg_isready 30 --health-interval 10s 31 --health-timeout 5s 32 --health-retries 5 33 strategy: 34 matrix: 35 node-version: [18.x, 20.x] 36 # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 37 steps: 38 - uses: actions/checkout@v4 39 - name: Use Node.js ${{ matrix.node-version }} 40 uses: actions/setup-node@v4 41 with: 42 node-version: ${{ matrix.node-version }} 43 - name: Install 44 run: yarn --frozen-lockfile 45 - name: Lint Check 46 run: yarn lint 47 - name: Build 48 run: yarn compile 49 - name: Coverage Upload 50 uses: codecov/codecov-action@v4 51 docker-build: 52 runs-on: ubuntu-22.04 53 if: github.event_name == 'pull_request' 54 needs: build 55 steps: 56 - uses: actions/checkout@v4 57 - name: Run build 58 run: docker build . --file Dockerfile