Skip to content

Commit a45478c

Browse files
boly38creharmony
authored andcommitted
Fix #8 add github actions
1 parent a1ced1e commit a45478c

File tree

5 files changed

+150
-4
lines changed

5 files changed

+150
-4
lines changed

.github/workflows/audit.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: nha-audit
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *'
6+
# Allows you to run this workflow manually from the Actions tab
7+
workflow_dispatch:
8+
9+
jobs:
10+
scan:
11+
name: npm audit
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
17+
node-version: [16.x]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
28+
cache-dependency-path: |
29+
package-lock.json
30+
31+
- name: Install dependencies
32+
# - run: npm ci # need package.json.lock
33+
run: |
34+
echo "install"
35+
npm install
36+
echo "show outdated (if any)"
37+
npm outdated --depth=3 || echo "you must think about update your dependencies :)"
38+
39+
- name: Npm audit
40+
uses: oke-py/[email protected]
41+
with:
42+
audit_level: moderate
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
dedupe_issues: true

.github/workflows/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# node-hook-action continuous integration
2+
name: nha-ci
3+
4+
# Controls when the action will run.
5+
on:
6+
# Triggers the workflow on push or pull request events but only for the prod branch
7+
push:
8+
branches: [ npmjs ]
9+
pull_request:
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
build:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
matrix:
23+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
24+
node-version: [16.x]
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
# cache: 'npm'
34+
# cache-dependency-path: |
35+
# package-lock.json
36+
37+
- name: Install dependencies
38+
# - run: npm ci # need package.json.lock
39+
run: npm install
40+
41+
- name: Run tests
42+
env:
43+
MT_MONGO_USER: root
44+
MT_MONGO_PWD: mypass
45+
run: npm run test
46+
47+
- name: Report coverage
48+
continue-on-error: true
49+
uses: romeovs/[email protected]
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
lcov-file: ./coverage/lcov.info
53+
54+
- name: Npm audit
55+
uses: oke-py/[email protected]
56+
with:
57+
audit_level: moderate
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
dedupe_issues: true
60+
61+
- name: Publish NpmJS package
62+
if: github.ref == 'refs/heads/npmjs'
63+
run: |
64+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_DEPLOY_TOKEN }}" > .npmrc
65+
npm whoami # rely on .npmrc
66+
npm publish

.github/workflows/patch.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# create patch from 'main' branch
2+
name: nha-patch
3+
on:
4+
# Allows you to run this workflow manually from the Actions tab
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [16.x]
13+
14+
steps:
15+
- name: Git checkout
16+
uses: actions/checkout@v2
17+
with:
18+
ref: 'npmjs'
19+
token: ${{ secrets.GH_ACTIONS_TOKEN }}
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Patch
27+
run: |
28+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
29+
git config --global user.name 'github-actions[bot]'
30+
git fetch --all
31+
git checkout main
32+
npm version patch
33+
git branch -f npmjs
34+
git push origin main npmjs --tags
File renamed without changes.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@
2828
"dependencies": {
2929
"async": "^3.2.0",
3030
"body-parser": "^1.19.0",
31-
"chai": "^4.2.0",
32-
"chai-http": "^4.3.0",
3331
"crypto": "^1.0.1",
3432
"express": "^4.17.1",
3533
"jsonpath": "^1.0.2",
36-
"mocha": "^8.2.1",
3734
"moment": "^2.29.1",
3835
"shelljs": "^0.8.4",
39-
"supertest": "^6.0.1",
4036
"uuid": "^8.3.2"
37+
},
38+
"devDependencies": {
39+
"chai": "^4.2.0",
40+
"chai-http": "^4.3.0",
41+
"mocha": "^9.1.3",
42+
"supertest": "^6.0.1"
4143
}
4244
}

0 commit comments

Comments
 (0)