Skip to content

Merge pull request #401 from bervProject/dependabot/npm_and_yarn/cros… #987

Merge pull request #401 from bervProject/dependabot/npm_and_yarn/cros…

Merge pull request #401 from bervProject/dependabot/npm_and_yarn/cros… #987

Workflow file for this run

name: Node CI
on:
push:
branches: [main]
tags:
- v*
pull_request:
branches: [main]
env:
IMAGE_NAME: koa-boilerplate
jobs:
build:
runs-on: ubuntu-22.04
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
ports:
- 5432:5432
# Provide the password for postgres
env:
POSTGRES_PASSWORD: db_test_pass
POSTGRES_DB: database_test
# 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: [20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: yarn, yarn build, yarn test
run: |
yarn --frozen-lockfile
yarn build
NODE_ENV=test npx sequelize-cli db:migrate
yarn test --forceExit
env:
CI: true
- uses: codecov/codecov-action@v5.0.2
if: ${{ matrix.node-version == '20.x' }}
name: Upload Coverage
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
docker-test:
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request'
needs: build
steps:
- uses: actions/checkout@v4
- name: Run tests
run: docker build . --file Dockerfile
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@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
bervproject/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}