Generating GIT_REPO urls
By default, Card data is saved to a private GitHub repository that you create. In order to make commits, the Hub needs to know which repo and the authentication information. This guide will help you compose the GIT_REPO
environment variable that serves this purpose.
- Create a private repository on GitHub
- Create a machine user account on GitHub and grant only the limited permissions to the specific repository that you want the Hub to write to.
- Log in as the machine user. Go to the Personal access tokens section of the settings, in the "Developer settings" section, and click on the "Generate new token" button.
- On the following page, enter a note so you remember this token is used with the Cardstack Hub, and click on the "repo" checkbox (Full control of private repositories). No other permissions are required. Then click on "Generate token" at the bottom of the page. Make sure to copy the token now as it will not be displayed again. See this image for an example.
- Once you have the token, you can now create the
GIT_REPO
url that is passed to theremoteUrl
attribute of the git realm card. It follows the formathttps://<username>:<token>@github.com/<org>/<reponame>.git
For example, if you generated the tokenabc123
, and your GitHub repository ishttps://github.com/cardstack/cardstack
, and your machine username iscardstack-deploy-user
, then yourremoteUrl
attribute would behttps://cardstack-deploy-user:abc123@github.com/cardstack/cardstack.git
The Cardstack Hub can only connect to remote git repositories over http
or https
, as isomorphic git doesn't yet support ssh transport protocol. For this reason, you will need to generate a personal access token to create a git https url to configure the hub with.
Personal access tokens have broad permissions - notably, you cannot create an access token that only works with a single repository, there is no equivalent of the ssh "deploy key" functionality with GitHub right now. Due to the broad permissions, it's strongly recommended to create a machine user account on GitHub and grant only the limited permissions to the specific repository that you want the Hub to write to.