Skip to content

Weekly NASCAR Data Update #31

Weekly NASCAR Data Update

Weekly NASCAR Data Update #31

name: Weekly NASCAR Data Update
on:
schedule:
- cron: '0 10 * * 1' # Runs at 00:00 on Monday
workflow_dispatch: # Manual triggering for testing
# push:
# branches:
# - dev # Explicitly allow running on dev branch
# - main
jobs:
update-nascar-data:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write # This is needed for creating issues
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::devtools
any::dplyr
any::glue
any::purrr
any::rlang
any::rvest
any::stringdist
any::stringr
any::roxygen2
any::scales
- name: Debug Run
id: debug-run
continue-on-error: true
run: |
Rscript inst/updates/run_debug.R
- name: Upload Debug Files
if: always()
uses: actions/upload-artifact@v3
with:
name: debug-files
path: inst/extdata/debug/
- name: Create Issue on Debug Failure
if: steps.debug-run.outcome == 'failure'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'NASCAR Data Update Debug Run Failed',
body: 'The debug run of the NASCAR data update script failed. Please check the GitHub Actions logs.'
})
- name: Production Run
if: steps.debug-run.outcome == 'success'
run: |
Rscript inst/updates/run_update.R
- name: Commit and Push Changes
id: production-run
if: steps.debug-run.outcome == 'success'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add data/*.rda
git commit -m "Update NASCAR data [automated]" || echo "No changes to commit"
git push
- name: Create Issue on Production Failure
if: steps.production-run.outcome == 'failure'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'NASCAR Data Production Update Failed',
body: 'The production run failed after successful debug. Please check the GitHub Actions logs.'
})