name: update-rapids

on:
  workflow_dispatch:
  schedule:
    - cron: "0 20 * * 1"  # Run once weekly

permissions:
  pull-requests: write
  contents: write

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

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # To use GitHub CLI

jobs:
  update-rapids:
    name: Check latest RAPIDS
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
      with:
        submodules: 'true'
    - name: Check latest RAPIDS and update conftest.sh
      run: |
        bash tests/buildkite/update-rapids.sh
    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v6
      if: github.ref == 'refs/heads/master'
      with:
        add-paths: |
          tests/buildkite
        branch: create-pull-request/update-rapids
        base: master
        title: "[CI] Update RAPIDS to latest stable"
        commit-message: "[CI] Update RAPIDS to latest stable"
      
