Newer
Older
thu-learn-downloader-optimized / .github / workflows / check.yaml
@liblaf liblaf on 1 Dec 2023 958 bytes ci: sync with template repository
name: Check

on:
  pull_request:

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - name: Check
        run: |
          function checks() {
            (gh pr checks ${{ github.event.pull_request.html_url }} || true) |
              grep --invert-match ${{ github.run_id }}
          }

          function count() {
            checks |
              cut --fields=2 |
              (grep --count "$@" || true)
          }

          while true; do
            count=$(count pending)
            if ((count > 0)); then
              echo "Waiting for $count checks to complete..."
              sleep 10
            else
              break
            fi
          done

          count=$(count fail)
          if ((count > 0)); then
            echo "$count checks failed"
            exit 1
          else
            echo "All checks passed"
            exit 0
          fi
        env:
          GH_TOKEN: ${{ github.token }}