name: Clean PR checks
on:
  workflow_dispatch:
    inputs:
      pr:
        description: PR to be cleaned
        required: true
      checks:
        description: Checks to be cleaned
        required: true
        default: 'build/O2/o2,build/AliceO2/O2/o2/macOS,build/O2/fullCI'
      owner:
        description: Organization
        required: true
        default: 'alisw'
      repo:
        description: Repository
        required: true
        default: 'AliPhysics'

jobs:
  cleanup_pr_checks:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Python 3.7
        uses: actions/setup-python@v1
        with:
          python-version: 3.7
      - name: Install ali-bot
        run: |
          sudo apt-get update -y
          sudo apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev
          python -m pip install --upgrade pip
          pip install git+https://github.com/alisw/ali-bot@master
      - uses: octokit/graphql-action@v2.x
        id: get_last_commit_for_pr
        with:
          query: |
              {
                repository(owner: "${{ github.event.inputs.owner }}", name: "${{ github.event.inputs.repo }}") {
                  url
                  pullRequest(number:${{ github.event.inputs.pr }}) {
                    commits(last: 1) {
                      nodes {
                        commit {
                          oid
                        }
                      }
                    }
                  }
                }
              }
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Cleanup tests
        run: |-
          set -x
          cat <<\EOF > results.json
          ${{ steps.get_last_commit_for_pr.outputs.data }}
          EOF
          COMMIT=$(jq -r '.repository.pullRequest.commits.nodes[].commit.oid' results.json)
          echo $COMMIT
          for check in `echo ${{ github.event.inputs.checks }} | tr , \\\\n`; do
            set-github-status -c ${{ github.event.inputs.owner }}/${{ github.event.inputs.repo }}@$COMMIT -s $check/pending
          done
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Add Action to clean up tests
Add Action to clean up tests