You've already forked library-registry
mirror of
https://github.com/arduino/library-registry.git
synced 2025-07-29 14:01:15 +03:00
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.
This commit is contained in:
58
.github/workflows/check-workflows.yml
vendored
Normal file
58
.github/workflows/check-workflows.yml
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
name: Check Workflows
|
||||||
|
|
||||||
|
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/*.yaml"
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/*.yaml"
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
schedule:
|
||||||
|
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
|
||||||
|
- cron: "0 8 * * TUE"
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Download JSON schema for GitHub Actions workflows
|
||||||
|
id: download-schema
|
||||||
|
uses: carlosperate/download-file-action@v1.0.3
|
||||||
|
with:
|
||||||
|
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
|
||||||
|
file-url: https://json.schemastore.org/github-workflow
|
||||||
|
location: ${{ runner.temp }}/github-workflow-schema
|
||||||
|
file-name: github-workflow.json
|
||||||
|
|
||||||
|
- name: Get week number for use in cache key
|
||||||
|
id: get-date
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=week-number::$(date --utc '+%V')"
|
||||||
|
|
||||||
|
- name: Load dependencies cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-ajv-cli-${{ steps.get-date.outputs.week-number }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-ajv-cli-
|
||||||
|
|
||||||
|
- name: Install JSON schema validator
|
||||||
|
run: sudo npm install --global ajv-cli
|
||||||
|
|
||||||
|
- name: Validate GitHub Actions workflows
|
||||||
|
run: |
|
||||||
|
# See: https://github.com/ajv-validator/ajv-cli#readme
|
||||||
|
ajv validate \
|
||||||
|
--strict=false \
|
||||||
|
-s "${{ steps.download-schema.outputs.file-path }}" \
|
||||||
|
-d "./.github/workflows/*.{yml,yaml}"
|
Reference in New Issue
Block a user