Process lotto analysis #1152
This file contains 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: Process lotto analysis | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 12 * * *" | |
jobs: | |
scheduled: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out this repo | |
uses: actions/checkout@v4 | |
- name: Check out data repo | |
uses: actions/checkout@v4 | |
with: | |
repository: fasmat/lotto-data | |
path: "data" | |
token: ${{ secrets.data_token }} | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: "4.1.1" | |
- name: Install packages | |
run: | | |
install.packages("minpack.lm") | |
install.packages("lattice") | |
shell: Rscript {0} | |
- name: Run analysis | |
run: | | |
source("analysis/helpers.r") | |
# only analyze last three years | |
data <- read.data("data/data/numbers.csv", "data/data/winnings.csv") | |
data <- data[data$Date > as.POSIXct(Sys.Date() - 3 * 365), ] | |
outdir <- "plots" | |
source("analysis/analysis-special.r") | |
source("analysis/analysis-general.r") | |
shell: Rscript {0} | |
- name: Commit updated data | |
run: |- | |
rm -r data | |
if [[ `git status --porcelain` ]]; then | |
echo "New data analyzed" | |
git config user.name "Auto Updater" | |
git config user.email "[email protected]" | |
git add -A | |
timestamp=$(date -u) | |
git commit -m "Auto-update data: ${timestamp}" || exit 0 | |
git push | |
fi |