daily_wbb_data #1086
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 WBB Data | |
| on: | |
| schedule: | |
| - cron: '0 7 18-31 10 *' | |
| - cron: '0 7 * 11-12 *' | |
| - cron: '0 7 * 1-3 *' | |
| - cron: '0 7 1-12 4 *' | |
| repository_dispatch: | |
| types: [daily_wbb_data] | |
| workflow_dispatch: | |
| inputs: | |
| start_year: | |
| required: false | |
| type: string | |
| end_year: | |
| required: false | |
| type: string | |
| jobs: | |
| update_wbb_data: | |
| runs-on: ${{ matrix.config.os }} | |
| name: Update WBB 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@v4 | |
| - 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/wehoop | |
| sportsdataverse/sportsdataverse-data | |
| ropensci/piggyback | |
| - name: Check wehoop_wbb_data_trigger for inputs | |
| if: ${{ github.event.client_payload.event_name == 'daily_wbb_data'}} | |
| shell: bash | |
| env: | |
| COMMIT_MESSAGE: ${{ github.event.client_payload.commit_message }} | |
| run: | | |
| # Extract `Start: YYYY` and `End: YYYY` from the upstream commit | |
| # message (the umbrella scrape workflow produces messages like | |
| # `WBB Raw Update (Start: 2026 End: 2026)`). The previous | |
| # `grep -oE '[0-9]+' | head -1` was too permissive — it grabbed | |
| # any digit run, so a multi-line commit message with embedded | |
| # numbers (PR refs, error codes, etc.) produced bogus | |
| # START_YEAR / END_YEAR values. The narrower | |
| # `Start:\s*\K[0-9]{4}` keeps the regex anchored to the | |
| # canonical token and only matches 4-digit years; falls | |
| # through to the empty-input fallback when no match is found. | |
| start=$(printf '%s' "$COMMIT_MESSAGE" | grep -oP 'Start:\s*\K[0-9]{4}' | head -1) | |
| end=$(printf '%s' "$COMMIT_MESSAGE" | grep -oP 'End:\s*\K[0-9]{4}' | head -1) | |
| echo "START_YEAR=$start" >> $GITHUB_ENV | |
| echo "END_YEAR=$end" >> $GITHUB_ENV | |
| - name: Check for empty inputs | |
| if: ${{ env.START_YEAR == ''}} | |
| shell: bash | |
| run: | | |
| echo START_YEAR=$(Rscript -e "cat(wehoop::most_recent_wbb_season())") >> $GITHUB_ENV | |
| echo END_YEAR=$(Rscript -e "cat(wehoop::most_recent_wbb_season())") >> $GITHUB_ENV | |
| - name: Update WBB Data ${{ env.START_YEAR }}-${{ env.END_YEAR }} | |
| shell: bash | |
| env: | |
| GITHUB_PAT: ${{ secrets.SDV_GH_TOKEN }} | |
| SPORTSDATAVERSE.UPLOAD.QUIET: FALSE | |
| SPORTSDATAVERSE.UPLOAD.MAX_TIMES: 20 | |
| run: | | |
| echo $(pwd) | |
| bash scripts/daily_wbb_R_processor.sh -s ${{ env.START_YEAR }} -e ${{ env.END_YEAR }} |