-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.87 KB
/
validate-workflows.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
name: Validate GitHub Actions Workflows
on:
pull_request:
paths:
- ".github/workflows/*.ya?ml"
- "workflow-templates/*.ya?ml"
push:
paths:
- ".github/workflows/*.ya?ml"
- "workflow-templates/*.ya?ml"
# Scheduled trigger to catch workflow failure resulting from changes to the JSON schema
schedule:
# run every Saturday at 3 AM UTC
- cron: "0 3 * * 6"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
jobs:
validate:
runs-on: ubuntu-latest
env:
JSON_SCHEMA_FOLDER: etc/github-workflow-json-schema
JSON_SCHEMA_FILENAME: github-workflow.json
steps:
- name: Checkout local repository
uses: actions/checkout@v4
# See: https://github.com/carlosperate/download-file-action/blob/master/README.md
- name: Download JSON schema for GitHub Actions workflows
uses: carlosperate/[email protected]
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
file-url: https://json.schemastore.org/github-workflow
location: ${{ env.JSON_SCHEMA_FOLDER }}
file-name: ${{ env.JSON_SCHEMA_FILENAME }}
- name: Install JSON schema validator
run: sudo npm install --global ajv-cli
# See: https://github.com/ajv-validator/ajv-cli/blob/master/README.md
- name: Validate GitHub Actions workflows
run: |
ajv -s "${{ env.JSON_SCHEMA_FOLDER }}/${{ env.JSON_SCHEMA_FILENAME }}" -d "./.github/workflows/*.{yml,yaml}"
ajv -s "${{ env.JSON_SCHEMA_FOLDER }}/${{ env.JSON_SCHEMA_FILENAME }}" -d "./workflow-templates/*.{yml,yaml}"