Skip to content

Commit a5021de

Browse files
authored
Merge pull request #17 from per1234/check-npm
Add CI workflow to check project's npm configuration
2 parents 3b5b449 + 3294ce6 commit a5021de

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/check-npm.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Check npm
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-npm.yml"
8+
- "**/package.json"
9+
- "**/package-lock.json"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/check-npm.yml"
13+
- "**/package.json"
14+
- "**/package-lock.json"
15+
schedule:
16+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
17+
- cron: "0 8 * * TUE"
18+
workflow_dispatch:
19+
repository_dispatch:
20+
21+
jobs:
22+
validate:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Download JSON schema for package.json
30+
id: download-schema
31+
uses: carlosperate/[email protected]
32+
with:
33+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
34+
file-url: https://json.schemastore.org/package.json
35+
location: ${{ runner.temp }}/package-json-schema
36+
file-name: package-json-schema.json
37+
38+
- name: Install JSON schema validator
39+
# package.json schema is draft-04, which is not supported by ajv-cli >=4.
40+
run: sudo npm install --global [email protected]
41+
42+
- name: Validate GitHub Actions workflows
43+
run: |
44+
# See: https://github.com/ajv-validator/ajv-cli#readme
45+
ajv validate \
46+
-s "${{ steps.download-schema.outputs.file-path }}" \
47+
-d "./**/package.json"
48+
49+
check-manifest:
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v2
55+
56+
- name: Install dependencies
57+
run: npm install
58+
59+
- name: Check manifest
60+
run: git diff --color --exit-code package-lock.json

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)