Update validate.yml (#1) #77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Schemas | |
| on: | |
| push: | |
| branches: ["main"] | |
| tags-ignore: ["*"] # <- do not run this workflow for tags | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| name: validate | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_COLOR: "1" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Always checkout the exact SHA for PRs/pushes | |
| ref: ${{ github.sha }} | |
| - name: Normalize git on runner (LF) | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Validate schemas | |
| run: npm run validate:schemas | |
| - name: Validate examples | |
| run: npm run validate:examples | |
| # Regenerate checksums only on branches (not tags) | |
| - name: Generate checksums | |
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| run: node scripts/generate-checksums.mjs schemas/v1.0.0 checksums.txt | |
| # Compare checksums only on branches (not tags) | |
| - name: Verify checksums are current | |
| if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| run: git diff --exit-code checksums.txt | |
| # Upload artifact on failure to help debug | |
| - name: Upload checksums artifact (for debugging) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: checksums.txt | |
| path: checksums.txt |