jasdumas / the-republic

Local Connecticut Election & Voter Data Analytics Projects πŸ‡ΊπŸ‡Έ
https://jasdumas.github.io/the-republic/
MIT License
1 stars 0 forks source link

Cron jobs #1

Open jasdumas opened 7 years ago

jasdumas commented 7 years ago

Trying some things out by following Ben's issue: https://github.com/SustainSB/sustainsb.github.io/issues/2#issuecomment-304355281 . hence the newer files in the last commit for _push.sh and _render.sh. Stuck on encrypting my GH PAT 😒

Trying out the Cron daily build on travis now

jasdumas commented 7 years ago

Detailed Instructions to add from Ben's above^:

pre-requisites: GitHub repository creation with content

  1. Create DESCRIPTION file in RStudio and complete each section in the newly created file:
library(devtools)
create_description()
  1. Enable Travis-ci for the specific repo

screen shot 2017-11-03 at 6 04 53 pm

  1. Create .travis.yml file

  2. Add the build badge [![](https://api.travis-ci.org/username/repo.svg?branch=master)](https://travis-ci.org/username/repo)

  3. Create Personal Access Token at www.github.com/settings/tokens and paste value into file outside repo, eg /FOLDER_LOCATION/.gh-token-the-republic-push

  4. Create _push.sh file

#!/bin/sh

# info: https://github.com/SustainSB/sustainsb.github.io/issues/2
export GH_OWNER=jasdumas
export GH_REPO=the-republic
export GH_BRANCH=master

# setup git
git config --global user.email "jasmine.dumas@gmail.com"
git config --global user.name "jasdumas"
git config --global push.default matching

# git commit
git checkout ${GH_BRANCH}
git add --all
git commit -am "Travis $TRAVIS_EVENT_TYPE [skip ci]: build $TRAVIS_BUILD_NUMBER"

# git push
git remote add upstream "https://${GH_TOKEN}@github.com/${GH_OWNER}/${GH_REPO}.git"
git push -q upstream ${GH_BRANCH}

AND the _render.sh file

#!/usr/bin/env Rscript

library(rmarkdown)

#rmds = list.files('.', '*.\\.Rmd')
#rmds = c('prep_layers.Rmd')
#rmds = c('test.Rmd')
rmds = c('web_scraping_sots_election_app.Rmd')

for (rmd in rmds){
  rmarkdown::render(rmd)
}
  1. Download the Travis-CI encryption CLI tool
gem install travis
  1. Execute this in Terminal (CL) which adds (even if there are cat errors, if you go checkout the travis file it should have been added to the env: > global: > secure: lines at the end of the script):
cd the-republic
echo GH_TOKEN=`cat /Users/jasminedumas/Desktop/GitHub Clone Repos/.gh-token-the-republic-push` | travis encrypt --add
  1. Commit & push it (real good) to GitHub πŸ˜„