Skip to content

Merge pull request #775 from bervProject/dependabot/npm_and_yarn/feat… #1209

Merge pull request #775 from bervProject/dependabot/npm_and_yarn/feat…

Merge pull request #775 from bervProject/dependabot/npm_and_yarn/feat… #1209

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ main ]
tags:
- v*
pull_request:
branches: [ main ]
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: feathersjs-boilerplate
jobs:
build:
runs-on: ubuntu-22.04
services:
# Label used to access the service container
postgres:
ports:
- 5432:5432
# Docker Hub image
image: postgres:15-alpine
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: feathers
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
node-version: [18.x, 19.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: yarn --frozen-lockfile
- name: Lint Check
run: yarn lint
- name: Build
run: yarn compile
- name: Test
run: yarn test
- name: Coverage Upload
uses: codecov/codecov-action@v3
docker-build:
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request'
needs: build
steps:
- uses: actions/checkout@v3
- name: Run build
run: docker build . --file Dockerfile
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
docker-push:
# Ensure test job passes before pushing image.
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
bervproject/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}