From 466041efa592f4fc796b4a81f289a140ccaf8700 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Tue, 30 Jul 2024 14:00:17 -0500 Subject: [PATCH] Add GitHub actions --- .github/workflows/validate-schemas.yml | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/validate-schemas.yml diff --git a/.github/workflows/validate-schemas.yml b/.github/workflows/validate-schemas.yml new file mode 100644 index 00000000..c833b597 --- /dev/null +++ b/.github/workflows/validate-schemas.yml @@ -0,0 +1,43 @@ +name: Validate JSON Schemas + +on: + pull_request: + paths: + - '**/theme.json' + - '**/styles/*.json' + - '**/assets/fonts/*.json' + +env: + PR_PATHS: >- + '**/theme.json' + '**/styles/*.json' + '**/assets/fonts/*.json' + HUSKY: 0 + +jobs: + validate-schema: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Fetch compare + run: | + git remote add upstream ${{ github.event.pull_request.base.repo.repositoryUrl }} + git fetch --no-write-fetch-head --depth=1 upstream ${{ github.event.pull_request.base.ref }} + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Validate JSON files + run: node theme-utils.mjs validate-schema $(git diff --name-only upstream/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.ref }} -- ${{ env.PR_PATHS }} | tr '\n' ' ')