library(knitr) library(icesDevops)
icesDevops functions to link to the ICES Devops webservices to allow users to interact with ICES TAF git repositoroes, and download summaries and data products from ICES TAF repositories.
icesDevops is implemented as an R package and available on GitHub
icesVMS can be installed from GitHub using the install_github
command from the
remotes
package:
library(remotes) install_github("ices-tools-prod/icesDevops")
For a summary of the package:
library(icesDevops) ?icesDevops
To create a PAT login to https://devops.ices.dk and follow the instructions in this link
once you have created the token you need to save it somewhere that is accessible only to you. You must store this token somewhere because you'll never be able to see it again, once you leave that page or close the windows. If you somehow goof this up, just generate a new PAT and, so you don't confuse yourself, delete the lost token.
It is customary to save the PAT as an environment variable in your
.Renviron
, with the name ICESDEVOPS_PAT
.
library(usethis) edit_r_environ()
usethis::edit_r_environ()
will open .Renviron
for editing. Add a
line like this, but substitute your PAT:
```{sh, eval = FALSE} ICESDEVOPS_PAT=8c70fd8419398999c9ac5bacf3192882193cadf2
Make sure this file ends in a newline! Lack of a newline can lead to silent failure to load this environment variable, which can be tricky to debug. Restart R and confirm your PAT is now available: ```r Sys.getenv("ICESDEVOPS_PAT") # or devops_pat()
To get a list of the repositories you have access to use the following conveinience function, what it does in more detail is listed below.
devops_repos()
At the lowest level, this is how this is done. First form the url,
then perform the GET request. Note you will need to have created a
Personal Access Token (PAT) and saved this in a variable called pat
for this line to work.
res <- devops_get( devops_url( "repositories", area = "git" ) ) res
once you have the response, you can extract the content, and parse into a simplyfied structure (where possible, lists are converted to data.frames)
cont <- httr::content(res, simplifyVector = TRUE) # only show some of the content, for simplicity repos <- cont$value repos[c("name", "webUrl")]
test_dir <- file.path(tempdir(), "test") if (dir.exists(test_dir)) unlink(test_dir, recursive = TRUE, force = TRUE)
# get repository list repos <- devops_repos() # get remote url remote_url <- repos$remoteUrl[repos$name == "test"] # clone (into a temporary directory) repo <- devops_clone( remote_url, local_dir = file.path(tempdir(), "test") ) repo
# move into repo and make changes old_dir <- setwd(workdir(repo)) # run taf.skeleton to ensure all taf files exist icesTAF::taf.skeleton() # as a test add some comments to the end of data.R cat("# some more comments on", date(), "\n", file = "data.R", append = TRUE) setwd(old_dir) git2r::status(repo) # add all files git2r::add(repo, path = "*") # commit git2r::commit(repo, all = TRUE, message = "test changes") # push! devops_push(repo)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.