name: validate
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
      - 1.23.X
  workflow_dispatch:
permissions: {}

jobs:
  json-yaml-validate:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # enable write permissions for pull request comments
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with: { persist-credentials: false }

      - name: json-yaml-validate
        id: json-yaml-validate
        uses: GrantBirki/json-yaml-validate@9bbaa8474e3af4e91f25eda8ac194fdc30564d96 # v4.0.0
        with:
          comment: "true" # enable comment mode
          exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions

  # General validations
  validate:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with: { persist-credentials: false }
      - name: Use Node.js 25
        uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
        with:
          node-version: 25

      - name: Validate language JSON files
        run: node ./extra/check-lang-json.js

      - name: Validate knex migrations filename
        run: node ./extra/check-knex-filenames.mjs

      - name: Validate package.json
        run: node ./extra/check-package-json.mjs
