Skip to content

Commit 63f7175

Browse files
committed
Add CI workflow to validate GitHub Actions workflows
On every push or pull request that affects the repository's GitHub Actions workflows, and periodically, validate them against the JSON schema.
1 parent 5d650ce commit 63f7175

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
+35
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

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
version: "3"
33

44
tasks:
5+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
6+
ci:validate:
7+
desc: Validate GitHub Actions workflows against their JSON schema
8+
vars:
9+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
10+
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
11+
WORKFLOW_SCHEMA_PATH:
12+
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
13+
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
14+
cmds:
15+
- |
16+
wget \
17+
--quiet \
18+
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
19+
{{.WORKFLOW_SCHEMA_URL}}
20+
- |
21+
npx \
22+
--package=ajv-cli \
23+
--package=ajv-formats \
24+
ajv validate \
25+
--all-errors \
26+
--strict=false \
27+
-c ajv-formats \
28+
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
29+
-d "{{.WORKFLOWS_DATA_PATH}}"
30+
531
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
632
general:check-formatting:
733
desc: Check basic formatting style of all files

0 commit comments

Comments
 (0)