-
Notifications
You must be signed in to change notification settings - Fork 16
85 lines (77 loc) · 2.89 KB
/
check-schema.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Check schema flow
on:
workflow_call:
inputs:
actions-ref:
description: "Version of actions, normally the same as workflow"
required: false
type: string
default: ""
azure-dir:
description: "Directory containing Azure Pipelines config files. Provide an empty string to skip checking on Azure Pipelines files."
default: ".azure/"
required: false
type: string
defaults:
run:
shell: bash
jobs:
schema:
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
with:
submodules: recursive
# if actions version is given install defined versions
- name: "[optional] Pull reusable 🤖 actions"
if: inputs.actions-ref != ''
uses: actions/checkout@v4
with:
ref: ${{ inputs.actions-ref }}
path: .cicd
repository: Lightning-AI/utilities
- name: "[optional] Install recommended dependencies"
if: inputs.actions-ref != ''
timeout-minutes: 5
run: |
pip install -r ./.cicd/requirements/gha-schema.txt
pip list | grep "check-jsonschema"
# otherwise fall back to using the latest
- name: "[default] Install recommended dependencies"
if: inputs.actions-ref == ''
timeout-minutes: 5
run: |
pip install -q check-jsonschema
pip list | grep "check-jsonschema"
- name: Scan repo
id: folders
run: python -c "import os; print('gh_actions=' + str(int(os.path.isdir('.github/actions'))))" >> $GITHUB_OUTPUT
# https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
- name: GitHub Actions - workflow
run: |
files=$(find .github/workflows -name '*.yml' -or -name '*.yaml' -not -name '__*')
for f in $files; do
echo $f;
check-jsonschema -v $f --builtin-schema "github-workflows";
done
# https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json
- name: GitHub Actions - action
if: steps.folders.outputs.gh_actions == '1'
run: |
files=$(find .github/actions -name '*.yml' -or -name '*.yaml')
for f in $files; do
echo $f;
check-jsonschema -v $f --builtin-schema "github-actions";
done
# https://github.com/microsoft/azure-pipelines-vscode/blob/main/service-schema.json
- name: Azure Pipelines
if: ${{ inputs.azure-dir != '' }}
env:
SCHEMA_FILE: https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/v1.208.0/service-schema.json
run: |
files=$(find ${{ inputs.azure-dir }} -name '*.yml' -or -name '*.yaml')
for f in $files; do
echo $f;
check-jsonschema -v $f --schemafile "$SCHEMA_FILE";
done