Skip to content

Instantly share code, notes, and snippets.

@randy3k
Created April 6, 2020 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randy3k/de833f37b2e3ec931fcca2448cd83d3e to your computer and use it in GitHub Desktop.
Save randy3k/de833f37b2e3ec931fcca2448cd83d3e to your computer and use it in GitHub Desktop.
preview private github repo
library(httpuv)
library(httr)
library(stringr)
app <- list(
call = function(req) {
paths <- str_split(req$PATH_INFO, "/")[[1]]
owner <- paths[2]
repo <- paths[3]
path <- str_c(paths[4:length(paths)])
r <- GET(
str_glue("https://raw.githubusercontent.com/{owner}/{repo}/master/{path}"),
add_headers(Authorization = paste("token", Sys.getenv("GITHUB_PAT")))
)
list(
status = 200L,
headers = list(
"Content-Type" = "text/html"
),
body = content(r, as = "text")
)
}
)
server <- runServer("0.0.0.0", 9454, app)
@randy3k
Copy link
Author

randy3k commented Apr 8, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment