Skip to content

Commit 3557e5a

Browse files
authored
Merge pull request #15 from arduino/scerza/workflow-check
Add CI workflow to validate GitHub Actions workflows
2 parents 88f3647 + ebae3f4 commit 3557e5a

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
2+
name: Check Workflows
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/*.ya?ml"
9+
- "Taskfile.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/*.ya?ml"
13+
- "Taskfile.ya?ml"
14+
schedule:
15+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
16+
- cron: "0 8 * * TUE"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
jobs:
21+
validate:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
- name: Install Task
29+
uses: arduino/setup-task@v1
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
version: 3.x
33+
34+
- name: Validate workflows
35+
run: task --silent ci:validate

Taskfile.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,29 @@ tasks:
129129
exit $STATUS
130130
'
131131
fi
132+
133+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
134+
ci:validate:
135+
desc: Validate GitHub Actions workflows against their JSON schema
136+
vars:
137+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
138+
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
139+
WORKFLOW_SCHEMA_PATH:
140+
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
141+
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
142+
cmds:
143+
- |
144+
wget \
145+
--quiet \
146+
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
147+
{{.WORKFLOW_SCHEMA_URL}}
148+
- |
149+
npx \
150+
--package=ajv-cli \
151+
--package=ajv-formats \
152+
ajv validate \
153+
--all-errors \
154+
--strict=false \
155+
-c ajv-formats \
156+
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
157+
-d "{{.WORKFLOWS_DATA_PATH}}"

0 commit comments

Comments
 (0)