From 8cfde9323baf22af2d56ff456ae9a12a0e74672a 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 | 45 ++++++++++++++++++++++++++ 1 file changed, 45 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..af23a5fe --- /dev/null +++ b/.github/workflows/validate-schemas.yml @@ -0,0 +1,45 @@ +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: + 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 }} + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + + - name: Fetch base branch + run: git fetch --quiet --prune --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} + + - name: Get JSON files list + run: echo "PR_MODIFIED_JSON_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.ref }} -- ${{ env.PR_PATHS }} | tr '\n' ' ')" >> $GITHUB_ENV + + - 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 ${{ env.PR_MODIFIED_JSON_FILES }}