-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could use_travis() turn on repo automatically? #971
Comments
Reading https://docs.travis-ci.com/api#with-a-github-token suggests this code should work: req <- httr::POST("https://api.travis-ci.org/auth/github",
body = list(github_token = github_pat()),
httr::accept("application/vnd.travis-ci.2+json"),
httr::verbose(),
encode = "json"
)
httr::content(req, "text") But it doesn't, and the error recommends contacting support. Since travis support never replies with anything useful, this doesn't seem worth pursuing at this time. |
Critical bit seems to be using the same user agent as their example: req <- httr::POST("https://api.travis-ci.org/auth/github",
body = list(github_token = github_pat()),
httr::accept("application/vnd.travis-ci.2+json"),
httr::verbose(),
httr::user_agent("MyClient/1.0.0"),
encode = "json"
)
httr::content(req) |
Complete process: library(httr)
# Get auth token using Github PAT -----------------------------------------
travis_token <- function() {
req <- POST("https://api.travis-ci.org/auth/github",
body = list(github_token = github_pat()),
accept("application/vnd.travis-ci.2+json"),
user_agent("MyClient/1.0.0"),
encode = "json"
)
stop_for_status(req)
token <- httr::content(req)$access_token
add_headers(Authorization = paste0("token ", token))
}
token <- travis_token()
# Determine repo id -------------------------------------------------------
repos <- content(GET("https://api.travis-ci.org/repos", token, query = list(slug = "hadley/monads")))
id <- repos[[1]]$id
# Set hook to active ------------------------------------------------------
req <- PUT("https://api.travis-ci.org/hooks",
body = list(hook = list(id = id, active = TRUE)),
encode = "json",
token
)
stop_for_status(req)
content(req)
# library(purrr)
# hooks <- content(GET("https://api.travis-ci.org/hooks", token))
# hooks %>% map_chr("uid")
# hooks %>% keep(~.$name == "monads") %>% str() |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
via github authentication from GITHUB_PAT
The text was updated successfully, but these errors were encountered: