Skip to content

Commit 0f16fc9

Browse files
committed
Add CI workflow to validate action.yml against JSON schema
This uses a community-generated schema, but it's well done and actively maintained.
1 parent 4e4af45 commit 0f16fc9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Validate action.yml
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/validate-action_yml.yml"
7+
- "action.yml"
8+
push:
9+
paths:
10+
- ".github/workflows/validate-action_yml.yml"
11+
- "action.yml"
12+
# Scheduled trigger to catch workflow failure resulting from changes to the JSON schema
13+
schedule:
14+
# run every Tuesday at 3 AM UTC
15+
- cron: "0 3 * * 2"
16+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
17+
workflow_dispatch:
18+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
19+
repository_dispatch:
20+
21+
jobs:
22+
validate:
23+
runs-on: ubuntu-latest
24+
25+
env:
26+
JSON_SCHEMA_FOLDER: etc/github-action-json-schema
27+
JSON_SCHEMA_FILENAME: github-action.json
28+
29+
steps:
30+
- name: Checkout local repository
31+
uses: actions/checkout@v2
32+
33+
# See: https://github.com/carlosperate/download-file-action/blob/master/README.md
34+
- name: Download JSON schema for action.yml
35+
uses: carlosperate/[email protected]
36+
with:
37+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json
38+
file-url: https://json.schemastore.org/github-action
39+
location: ${{ env.JSON_SCHEMA_FOLDER }}
40+
file-name: ${{ env.JSON_SCHEMA_FILENAME }}
41+
42+
- name: Install JSON schema validator
43+
run: sudo npm install --global ajv-cli
44+
45+
# See: https://github.com/ajv-validator/ajv-cli/blob/master/README.md
46+
- name: Validate action.yml
47+
run: ajv -s "${{ env.JSON_SCHEMA_FOLDER }}/${{ env.JSON_SCHEMA_FILENAME }}" -d action.yml

0 commit comments

Comments
 (0)