Skip to content

Instantly share code, notes, and snippets.

@tanho63
Last active May 13, 2020 19:15
Show Gist options
  • Save tanho63/3d0d807ee694b847b56c81b99d47703d to your computer and use it in GitHub Desktop.
Save tanho63/3d0d807ee694b847b56c81b99d47703d to your computer and use it in GitHub Desktop.
#### Snippet where I write csv files to https://github.com/DynastyProcess/data each week ####
write.csv(values_players,'../data/files/values-players.csv',row.names = FALSE)
write.csv(values_picks,'../data/files/values-picks.csv',row.names = FALSE)
write.csv(values,'../data/files/values.csv',row.names = FALSE)
write.csv(dp_playerids,'../data/files/db_playerids.csv',row.names = FALSE)
data_repo <- git2r::repository('../data') # Set up connection to repository folder
git2r::add(data_repo,'files/value*') # add specific files to staging of commit
git2r::add(data_repo,'files/db_*')
git2r::commit(data_repo,message = glue("GitHub Values Update for {Sys.time()}")) # commit the staged files with the chosen message
git2r::pull(data_repo,credentials = git2r::cred_user_pass(username = 'tanho63',password = '{password}')) # pull repo (and pray there are no merge commits)
git2r::push(data_repo,credentials = git2r::cred_user_pass(username = 'tanho63',password = '{password}')) # push commit
message(paste('Successfully uploaded to GitHub values as of',Sys.time())) # I have cron set up to pipe this message to healthchecks.io so that I can keep track if something is broken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment