name: Chain endpoints
on:
  schedule:
    # twice daily (mornings/afternoons, the latter being busy)
    # - cron:  '50 0/12 * * *'
    # once daily (early mornings, 02:50 GMT, generally not busy)
    - cron:  '50 2 * * *'

jobs:
  endpoints:
    if: github.repository == 'polkadot-js/apps'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: 'lts/*'
    - name: check
      env:
        CI_LOG: 123
      run: |
        yarn install --immutable | grep -v 'YN0013'
        yarn ci:chainEndpoints

    - name: issue
      if: ${{ failure() }}
      uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd
      env:
        GITHUB_TOKEN: ${{ secrets.GH_PAT_BOT }}
      with:
        filename: .github/chain-endpoints.md
        update_existing: true
