generated from algoan/nestjs-connector-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 7
69 lines (66 loc) · 1.88 KB
/
test-and-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Run Build and tests
on:
pull_request:
push:
branches-ignore:
- dependabot/**
- gh-pages
workflow_dispatch:
inputs:
ref:
description: |
The branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that event.
Otherwise, uses the default branch.
required: false
default: master
env:
NODE_ENV: test
jobs:
test:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
# Setup the node environment
- name: Use Node.js 14
uses: actions/setup-node@v3
with:
node-version: 14
cache: 'npm'
- run: npm i -g @nestjs/cli
# Install dependencies
- run: npm ci --prefer-offline
# Build application
- run: npm run build
# Run lint
- run: npm run lint
# Run unit tests
- run: npm run test
# Run functional tests with coverage
- run: npm run test:cov
publish:
runs-on: ubuntu-latest
needs:
- test
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'workflow_dispatch' }}
steps:
# Checkout the repository
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}
# Setup the node environment
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 14
# Install dependencies
- run: npm ci --prefer-offline
- run: npx semantic-release
env:
DOCKER_REGISTRY_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_GHA_PAT }}