-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (81 loc) · 2.69 KB
/
weekly-nascar-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Weekly NASCAR Data Update
on:
schedule:
- cron: '0 0 * * 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.'
})