R/runUpdateTweet.R

# library("tidyverse")
# library("rmarkdown")
# library("rstudioapi")

print(paste0("Web Site Build Started at: ", Sys.time()))

# https://stackoverflow.com/questions/28432607/pandoc-version-1-12-3-or-higher-is-required-and-was-not-found-r-shiny
# Sys.getenv("RSTUDIO_PANDOC")
# Then put that in your R script prior to calling the render command.

# Sys.setenv(RSTUDIO_PANDOC="--- insert directory here ---")

# Yet another option is to add this to an .Renviron file local to your project RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc Ref: csgillespie.github.io/efficientR/3-3-r-startup.html#renviron – Interfector Jan 25 '17 at 12:00


Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc")

rmarkdown::render_site(input = "~/MyJournalWatch", encoding = 'UTF-8')

Sys.sleep(10)

print(paste0("Web Site Build Ended at: ", Sys.time()))

Sys.sleep(1)

print(paste0("Git Update Started at: ", Sys.time()))


CommitMessage <- paste("updated on: ", Sys.time(), sep = "")
wd <- "~/MyJournalWatch"


# username <- "git config --global user.name 'sbalci' \n git config --global user.email 'drserdarbalci@gmail.com'"


# system(command = paste("cd ", wd, " \n"), wait = TRUE)
#
# system(command = "git add . \n", intern = TRUE, wait = TRUE)
#
# system(command = paste("git commit --message '", CommitMessage, "' \n"), wait = TRUE)
#
# system(command = "git push origin master \n", wait = TRUE)

# system(command = username, wait = TRUE)


setorigin <- "git remote set-url origin git@github.com:sbalci/MyJournalWatch.git \n"


gitCommand <- paste("cd ", wd, " \n git add . \n git commit --message '", CommitMessage, "' \n", setorigin, "git push origin master \n",  sep = "")

# gitCommand <- paste("cd ", wd, " \n git add --all \n git commit --message '", CommitMessage, "' \n git push --all \n",  sep = "")


system(command = paste(gitCommand, "\n") , intern = TRUE, wait = TRUE)



# myTerm <- rstudioapi::terminalCreate(show = FALSE)
# rstudioapi::terminalSend(
#     myTerm,
#     gitCommand
#     )
# Sys.sleep(1)
# repeat {
#     Sys.sleep(0.1)
#     if (rstudioapi::terminalBusy(myTerm) == FALSE) {
#         print("Code Executed")
#         break
#     }
# }


Sys.sleep(5)
 
print(paste0("Git Update Ended at: ", Sys.time()))

Sys.sleep(5)

# print(paste0("Tweet update infromation at: ", Sys.time()))

# library(rtweet)

# create_token(
#     app = "",
#     consumer_key = "",
#     consumer_secret = "")

# UpdateTweet <- paste0("My #JournalWatch The Articles I think Worth Reading has been updated on:", Sys.Date(), "https://sbalci.github.io/MyJournalWatch/ Please let me know articles to add. #PBPath #GIPath #pathology #pathologists #HPBpath #JournalWatch")

# rtweet::post_tweet(UpdateTweet)
sbalci/AutoJournalWatch documentation built on Aug. 13, 2020, 4:18 p.m.