Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Created March 3, 2018 13:28
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 dpastoor/ccc862a823629447fceb2265e3bed7af to your computer and use it in GitHub Desktop.
Save dpastoor/ccc862a823629447fceb2265e3bed7af to your computer and use it in GitHub Desktop.
repo_create <- try(gh::gh("POST /user/repos",
name = repo_nm,
description = paste("Website for workshop", repo_nm)),
silent = TRUE)
if (inherits(repo_create, "try-error")) {
stop("Can't create repository. Does it already exist?")
} else if (inherits(repo_create, "gh_response")) {
if (identical(attr(repo_create, "response")$status,
"201 Created"))
message("repo created")
} else stop("something went wrong in repository creation.")
## 2. import repository
owner_id <- repo_create$owner$login
res <- gh::gh("PUT /repos/:owner/:repo/import",
owner = owner_id, repo = repo_nm,
vcs_url = "https://github.com/swcarpentry/workshop-template",
vcs = "git",
.send_headers = c("Accept" = "application/vnd.github.barred-rock-preview"))
{
"languages": [
"R"
],
"tags": [
"try",
"error"
],
"references": [
"https://github.com/fmichonneau/shiny-workshop/blob/master/server.R#L77"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment