-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (84 loc) · 2.73 KB
/
node-lint.yml
File metadata and controls
94 lines (84 loc) · 2.73 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Node Lint
#
# Reusable workflow that runs two lint jobs in parallel:
#
# 1. npm lint — runs the npm lint script (ESLint, Prettier, etc.)
# 2. docker lint — runs hadolint against the Dockerfile
# skipped cleanly if no Dockerfile is found
#
# Usage in a consuming repository:
#
# jobs:
# lint:
# uses: orangitfi/platform-tooling/.github/workflows/node-lint.yml@<sha>
# with:
# working-directory: ./src
# dockerfile-path: Dockerfile
name: Node Lint
on:
workflow_call:
inputs:
working-directory:
description: "Directory containing package.json"
required: false
default: "."
type: string
lint-command:
description: "npm script to run for linting (e.g. lint, lint:check, lint:ci)"
required: false
default: "lint"
type: string
dockerfile-path:
description: "Path to the Dockerfile relative to the repository root"
required: false
default: "Dockerfile"
type: string
node-version:
description: "Node.js version to use (e.g. 20, 22)"
required: false
default: "20"
type: string
permissions:
contents: read
jobs:
npm-lint:
name: npm Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: npm ci
- name: Run lint
shell: bash
working-directory: ${{ inputs.working-directory }}
run: npm run ${{ inputs.lint-command }}
docker-lint:
name: Docker Lint (hadolint)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check for Dockerfile
id: check
shell: bash
run: |
if [ -f "${{ inputs.dockerfile-path }}" ]; then
echo "exists=true" >> "${GITHUB_OUTPUT}"
else
echo "exists=false" >> "${GITHUB_OUTPUT}"
echo "No Dockerfile found at '${{ inputs.dockerfile-path }}', skipping docker lint."
fi
- name: Lint Dockerfile
if: steps.check.outputs.exists == 'true'
uses: orangitfi/platform-tooling/.github/actions/docker-lint@a4ca46b0de8eda2f61573cfbd4164e538a7775a1 # pt-sha
with:
dockerfile: ${{ inputs.dockerfile-path }}
working-directory: ${{ inputs.working-directory }}