Skip to content

Commit 5ea1819

Browse files
committed
Refactor: merge reusable workflows
1 parent 2f8980a commit 5ea1819

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
workflow_call:
5+
inputs:
6+
enable_eslinter:
7+
description: 'Enable the ES-Linter for this repository'
8+
type: boolean
9+
required: false
10+
default: false
11+
enable_jsonlinter:
12+
description: 'Enable the JSON-Linter for this repository'
13+
type: boolean
14+
required: false
15+
default: false
16+
enable_yamllinter:
17+
description: 'Enable the YAML-Linter for this repository'
18+
type: boolean
19+
required: false
20+
default: false
21+
enable_stylelinter:
22+
description: 'Enable the Style-Linter for this repository'
23+
type: boolean
24+
required: false
25+
default: false
26+
repository:
27+
description: 'The repository that needs linting'
28+
type: string
29+
default: ${{ github.repository }}
30+
required: false
31+
ref:
32+
description: 'The branch, tag or SHA that needs linting'
33+
type: string
34+
required: false
35+
default: ${{ github.ref }}
36+
37+
eslinter-config:
38+
description: 'The location of the configuration file'
39+
type: string
40+
required: false
41+
default: './tools/linters/eslint.config.js'
42+
stylelinter-pattern:
43+
description: 'The file-pattern to match files that are being linted'
44+
type: string
45+
required: false
46+
default: '**/*.{css,scss,sass}'
47+
stylelinter-config:
48+
description: 'The location of the linter-configuration'
49+
type: string
50+
required: false
51+
default: 'tools/linters/.stylelintrc.json'
52+
yamllinter-config:
53+
description: 'The location of the linter-configuration'
54+
type: string
55+
required: false
56+
default: ''
57+
58+
jobs:
59+
ecmascript-linter:
60+
if: inputs.enable_eslinter == true
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- name: Install NodeJS
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: latest
68+
69+
- name: Checkout Code
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
repository: ${{ inputs.repository }}
74+
ref: ${{ inputs.ref }}
75+
76+
- name: Install ESLint
77+
run: |
78+
npm install eslint eslint-config
79+
80+
- name: Lint JavaScript
81+
run: ./node_modules/.bin/eslint --config=${{ inputs.eslinter-config }}
82+
env:
83+
DEBUG: eslint:languages:js
84+
85+
json-linter:
86+
if: inputs.enable_jsonlinter == true
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- name: Checkout Code
91+
uses: actions/checkout@v4
92+
with:
93+
fetch-depth: 0
94+
repository: ${{ inputs.repository }}
95+
ref: ${{ inputs.ref }}
96+
97+
- name: Lint JSON
98+
uses: limitusus/json-syntax-check@v2
99+
100+
style-linter:
101+
if: inputs.enable_stylelinter == true
102+
runs-on: ubuntu-latest
103+
104+
steps:
105+
- name: Install NodeJS
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: latest
109+
110+
- name: Checkout Code
111+
uses: actions/checkout@v4
112+
with:
113+
fetch-depth: 0
114+
repository: ${{ inputs.repository }}
115+
ref: ${{ inputs.ref }}
116+
117+
- name: Install StyleLint
118+
run: npm install stylelint stylelint-config-standard
119+
120+
- name: Lint stylesheets
121+
run: ./node_modules/.bin/stylelint -f verbose -c=${{ inputs.stylelinter-config }} ${{ inputs.stylelinter-pattern }}
122+
123+
yaml-linter:
124+
if: inputs.enable_yamllinter == true
125+
runs-on: ubuntu-latest
126+
127+
steps:
128+
- name: Checkout Code
129+
uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 0
132+
repository: ${{ inputs.repository }}
133+
ref: ${{ inputs.ref }}
134+
135+
- name: Lint YAML
136+
uses: ibiqlik/action-yamllint@v3.1.1
137+
with:
138+
config_file: ${{ inputs.yamllinter-config }}

0 commit comments

Comments
 (0)