daily_mbb_data #1224
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update MBB Data | |
| on: | |
| schedule: | |
| - cron: '0 7 18-31 10 *' | |
| - cron: '0 7 * 11-12 *' | |
| - cron: '0 7 * 1-3 *' | |
| - cron: '0 7 1-30 4 *' | |
| repository_dispatch: | |
| types: [daily_mbb_data] | |
| workflow_dispatch: | |
| inputs: | |
| start_year: | |
| required: false | |
| description: "Start Year (e.g., 2023)" | |
| type: string | |
| end_year: | |
| required: false | |
| description: "End Year (e.g., 2023)" | |
| type: string | |
| use_python_build: | |
| required: false | |
| description: "Use the python mbb_data_build processor instead of R (default: R)" | |
| type: boolean | |
| default: false | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| update_mbb_data: | |
| runs-on: ${{ matrix.config.os }} | |
| name: Update MBB Data ${{ inputs.start_year }}-${{ inputs.end_year }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - { os: "windows-latest", r: "release" } | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| R_KEEP_PKG_SOURCE: yes | |
| START_YEAR: ${{ inputs.start_year }} | |
| END_YEAR: ${{ inputs.end_year }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v5 | |
| - name: Setting up R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: ${{ matrix.config.r }} | |
| http-user-agent: ${{ matrix.config.http-user-agent }} | |
| - uses: r-lib/actions/setup-pandoc@v2 | |
| - name: Setting up R dependencies | |
| uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| cache-version: 1 | |
| extra-packages: | | |
| sportsdataverse/hoopR | |
| sportsdataverse/sportsdataverse-data | |
| ropensci/piggyback | |
| - name: Set up uv (for the python build) | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Sync python build deps | |
| shell: bash | |
| run: uv sync --project python | |
| - name: Check hoopR_mbb_data_trigger for inputs | |
| if: ${{ github.event.client_payload.event_name == 'daily_mbb_data'}} | |
| shell: bash | |
| run: | | |
| echo START_YEAR=$(echo "${{ github.event.client_payload.commit_message}}" | grep -o -E '[0-9]+' | head -1) >> $GITHUB_ENV | |
| echo END_YEAR=$(echo "${{ github.event.client_payload.commit_message}}" | grep -o -E '[0-9]+' | tail -1) >> $GITHUB_ENV | |
| - name: Check for empty inputs | |
| if: ${{ env.START_YEAR == ''}} | |
| shell: bash | |
| run: | | |
| echo START_YEAR=$(Rscript -e "cat(hoopR::most_recent_mbb_season())") >> $GITHUB_ENV | |
| echo END_YEAR=$(Rscript -e "cat(hoopR::most_recent_mbb_season())") >> $GITHUB_ENV | |
| - name: Update MBB Data ${{ env.START_YEAR }}-${{ env.END_YEAR }} | |
| shell: bash | |
| env: | |
| GITHUB_PAT: ${{ secrets.SDV_GH_TOKEN }} | |
| # gh CLI (python publish) needs cross-repo write to sportsdataverse-data; | |
| # the default github.token only reaches this repo. R uses GITHUB_PAT above. | |
| GH_TOKEN: ${{ secrets.SDV_GH_TOKEN }} | |
| SPORTSDATAVERSE.UPLOAD.QUIET: FALSE | |
| SPORTSDATAVERSE.UPLOAD.MAX_TIMES: 20 | |
| run: | | |
| echo $(pwd) | |
| # Python is the default (validated end-to-end in CI: all 11 datasets | |
| # build + publish). Set use_python_build=false to fall back to R. | |
| if [ "${{ inputs.use_python_build }}" = "false" ]; then | |
| bash scripts/daily_mbb_R_processor.sh -s ${{ env.START_YEAR }} -e ${{ env.END_YEAR }} | |
| else | |
| bash scripts/daily_mbb_python_processor.sh -s ${{ env.START_YEAR }} -e ${{ env.END_YEAR }} | |
| fi |