name: check-extensions

on:
  push:
    branches:
      - main
      - latest
  pull_request:

# If new code is pushed to a PR branch, then cancel in progress workflows for that PR.
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

defaults:
  run:
    shell: bash -xe {0}

jobs:
  check-build-verify-toml-schema:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8

      - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Populate the nix store
        run: nix develop --command echo

      - name: Run `obelisk generate config-schema`
        run: |
          nix develop --command scripts/regenerate-wit-extensions.sh
          if [ -n "$(git status --porcelain)" ]; then
            echo "::error::Uncommitted changes after running 'regenerate-wit-extensions.sh'"
            exit 1
          fi
