14 Git Backed Content
Content may be deployed to RStudio Connect directly from a remote Git repository. Content will automatically fetch from the associated remote Git repository and re-deploy. This allows for integration with Git-centric workflows and continuous deployment automation.
NOTE: Support for Git backed content is dependent on an acceptable version of Git being present in the RStudio Connect deployment environment, as described in the Admin Guide.
Git backed content may be distinguished from other content by the presence of the text “from Git” in the content description as well as a Git metadata section in the content Settings -> Info panel.
14.1 Caveats
Git backed content cannot be deployed via other means, such as by publishing
from the RStudio IDE or rsconnect::deployApp
.
The current support for authenticating with private Git repositories is limited to a single set of credentials which must be configured on the Connect server. See the Admin guide for details.
NOTE: These instructions are limited to content using R such as Shiny apps, reports, or static plots. Generating the appropriate manifest for Python content like Jupyter Notebooks or reticulated R and Python content is not readily available. Please contact # support@rstudio.com if you’re interested.
14.2 Publishing
The first step is to create a manifest.json
file associated with the content
you want RStudio Connect to track and deploy. The manifest file describes
things like the content type (report, Shiny app, plumber API, etc.) and the
content’s dependencies. The manifest can be created by calling the R function
rsconnect::writeManifest
from within your project. Depending on the structure
of your project, you may need to supply additional arguments to the function.
For example:
rsconnect::writeManifest(
appDir = ".", # the directory containing your content
appFiles = c("app.R", "helpers.R", "data/samples.csv"), # any supporting files
appPrimaryDoc = "app.R", # if there are more than one possible documents, e.g. if you have multiple RMDs
)
After the manifest.json
is generated, add and commit it to your local Git
working copy, and be sure to push to the remote Git repository so that Connect
can see the manifest.json
after fetching. This is roughly the equivalent done
in a terminal:
git add manifest.json
git commit -m 'Adding manifest.json for RStudio Connect deployment'
git push
For more examples of manifest.json
generation and management, see “Creating
a Bundle” in the API Cookbook.
Connect users must have at least the publisher
role in order to create new
content from a Git repository.
14.2.1 Publishing via wizard
On the “Content” page, there is a button near the top labeled “New Content”. Clicking on this button will expand a menu which contains an item called “New Content from Git Repo”, which may be clicked to launch a new content wizard.
The new content wizard will first prompt for a Git repo URL, which may use
https://
(recommended) or http://
remotes.
NOTE: Repository URLs must not contain authorization. Private repository access requires configuration of
GitCredential.Host
,GitCredential.Username
, andGitCredential.Password
, as described in the Admin Guide.
Once the repository URL has been entered, the next step will require specifying a branch name. A selection of candidate branch names collected from the remote repository will be listed.
Once the branch name has been entered, the next step will require specifying a
target directory. The directory names listed will have been determined by
searching for directories containing a manifest.json
file.
Once the target directory has been entered, an initial deployment will be triggered.
14.3 Automated deployment
Connect will periodically check all Git backed content for updates. If the updated repository is found to contain changes to the relevant branch and path specified, a new deployment will automatically be triggered. Such an update may be from new commit(s) pushed to the remote Git repository, or from another branch being merged into the target branch such as when merging a pull request.
Automatic updates may be disabled or enabled in the Git metadata section in the Settings -> Info panel.
14.4 Immediate deployment
Git backed content may be immediately checked for updates and potentially redeployed by clicking the “Update Now” button in the content Settings -> Info panel.