Skip to content

Node CI with NPM

Node CI with NPM #146

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 CI with NPM
on:
push:
branches:
- master
- "release/**"
pull_request:
branches:
- master
- "release/**"
workflow_dispatch:
release:
types:
- published
schedule:
- cron: "0 12 * * 0" # Every Sunday, at midday
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 21.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v4
id: cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node${{ matrix.node-version }}-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run linter over tests
run: |
npm install prettier
npx prettier -c test/**/*.ts
- name: Run integration tests with NPM
if: ${{ matrix.node-version == '18.x' &&
github.repository_owner == 'onfido' }}
run: npm test -- -i
env:
ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }}
ONFIDO_SAMPLE_APPLICANT_ID: ${{ secrets.ONFIDO_SAMPLE_APPLICANT_ID }}
ONFIDO_SAMPLE_VIDEO_ID_1: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_1 }}
ONFIDO_SAMPLE_VIDEO_ID_2: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_2 }}
ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }}
ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }}
publish:
runs-on: ubuntu-latest
needs: integration-tests
environment: delivery
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
ref: master
- uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- name: Validate release
uses: onfido/onfido-actions/release-check@main
- name: Install dependencies
run: npm ci
- name: Build and publish package
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
- name: Update and commit CHANGELOG.md
uses: onfido/onfido-actions/update-changelog@main