-
Notifications
You must be signed in to change notification settings - Fork 9
69 lines (57 loc) · 1.95 KB
/
check-npm.yml
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: Check npm
env:
# See: https://github.com/actions/setup-node/#readme
NODE_VERSION: 16.x
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-npm.ya?ml"
- "**/package.json"
- "**/package-lock.json"
pull_request:
paths:
- ".github/workflows/check-npm.ya?ml"
- "**/package.json"
- "**/package-lock.json"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download JSON schema for package.json
id: download-schema
uses: carlosperate/download-file-action@v1
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
file-url: https://json.schemastore.org/package.json
location: ${{ runner.temp }}/package-json-schema
file-name: package-json-schema.json
- name: Install JSON schema validator
# package.json schema is draft-04, which is not supported by ajv-cli >=4.
run: sudo npm install --global [email protected]
- name: Validate GitHub Actions workflows
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "./**/package.json"
check-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Check package-lock.json
run: git diff --color --exit-code package-lock.json