|
| 1 | +# How to open notebooks from a private Git repository |
| 2 | + |
| 3 | +This guide shows you how to configure a Git file storage in your Livebook Teams organization, allowing team members to access shared notebooks from a private Git repository inside an [app server](/teams_concepts.md#app-server). |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- Membership in a [Livebook Teams](https://livebook.dev/teams) organization |
| 10 | +- A private Git repository (GitHub, GitLab, Bitbucket, etc.) |
| 11 | + |
| 12 | +> #### Livebook version requirement {: .info} |
| 13 | +> Requires Livebook v0.18 or newer. |
| 14 | +
|
| 15 | + |
| 16 | +## Add a Git file storage to your Teams workspace |
| 17 | + |
| 18 | +1. Open Livebook |
| 19 | +2. Navigate to your Teams workspace page by clicking on the team name in the sidebar |
| 20 | +3. Scroll to the "File storages" section and click **Add file storage** |
| 21 | +4. Select **Git** as the file storage type |
| 22 | +5. Fill in the Git repository details: |
| 23 | + - **Repository URL **: Enter the SSH URL of your Git repository (e.g., `[email protected]:username/repo-name.git`) |
| 24 | + - **Branch**: Specify the branch to use (e.g., `main`) |
| 25 | + - **Private key**: Paste an SSH private key that has access to the repository (read-only access is enough) |
| 26 | +6. Click **Add** to save the configuration |
| 27 | + |
| 28 | +Once configured, the Git file storage will be synced across all team members and Livebook app servers that belong to your Teams organization. |
| 29 | + |
| 30 | +> #### Which SSH private key should I use? {: .tip} |
| 31 | +> Livebook connects to Git repositories over SSH, so you need to provide a private key with access to the repo. |
| 32 | +> |
| 33 | +> The recommended way is to create a new SSH key pair and add the public key as a deploy key for your Git repository inside your Git provider ([GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#set-up-deploy-keys), [GitLab](https://docs.gitlab.com/user/project/deploy_keys/#create-a-project-deploy-key), [Bitbucket](https://support.atlassian.com/bitbucket-cloud/docs/set-up-repository-access-keys-on-linux/), etc.), then use the private key for the Livebook configuration. |
| 34 | +> |
| 35 | +> Livebook only needs **read-only access**, so when adding the deploy key to your Git repo, you can grant read-only permissions only. |
| 36 | +
|
| 37 | +## Open a notebook from the Git repository |
| 38 | + |
| 39 | +After adding the Git file storage, members and app servers of your Teams organization can access notebooks stored in the repository: |
| 40 | + |
| 41 | +1. From the Livebook home page, click **Open** to open a notebook |
| 42 | +2. Make sure you're in the **From storage** tab, and click on the file storage dropdown, saying "Disk" |
| 43 | +3. Click on the Git file storage you configured (it will be listed with your repository URL) |
| 44 | +4. Browse the repository files and click on the notebook file you want to open |
| 45 | +5. Click **Fork** to open the notebook in a new session |
| 46 | + |
| 47 | +The notebook will open and be ready to use. |
| 48 | + |
| 49 | +It's worth noting that **Livebook treats notebooks inside a Git file storage as read-only**. That's |
| 50 | +why you have to "fork" the notebook, which creates a copy. Any changes you make are local to your session and won't affect the original file in the Git repository. |
| 51 | + |
| 52 | +## Examples of when this feature is useful |
| 53 | + |
| 54 | +This feature is particularly useful when working inside an [app server](/teams_concepts.md#app-server) from your Teams organization and you need to open shared notebooks stored in a Git repository. |
| 55 | + |
| 56 | +Common use cases include: |
| 57 | + |
| 58 | +* **Templates and boilerplate** - Access frequently needed code inside an app server |
| 59 | +* **Runbooks** - Open operational runbooks directly in your app server to interact with production systems |
| 60 | + |
| 61 | +## Examples of when this feature is not needed |
| 62 | + |
| 63 | +### Sharing notebooks with team members for local development |
| 64 | + |
| 65 | +If your team members need to edit and collaborate on notebooks in their local Livebook instances, use standard Git workflows instead: |
| 66 | + |
| 67 | +1. Team members clone the Git repository to their local machines |
| 68 | +2. Open notebooks directly from the cloned repository |
| 69 | +3. Edit, commit, and push changes using Git |
| 70 | + |
| 71 | +**Use Git file storage when**: You need to access the notebook from an app server, since app servers don't have direct access to your Git repository. |
| 72 | + |
| 73 | +### Deploying Livebook apps |
| 74 | + |
| 75 | +If you want to give someone access to a Livebook app (not edit the notebook): |
| 76 | + |
| 77 | +1. [Deploy your notebook as a Livebook app](deploy_app.md) |
| 78 | +2. Share your app server URL with users |
| 79 | + |
| 80 | +This allows users to use the app without notebook editing capabilities. |
| 81 | + |
| 82 | +**Use Git file storage when**: Team members need to open shared notebooks as regular notebooks inside an app server, not as deployed apps. |
| 83 | + |
| 84 | +## Security |
| 85 | + |
| 86 | +Your SSH private key is encrypted end-to-end and never accessible to Livebook Teams in plaintext. |
| 87 | + |
| 88 | +Livebook encrypts your SSH private key locally using your Teams key before sending it to Livebook Teams servers. When a Git file storage is added or edited, team members' Livebook instances and app servers receive the encrypted key and decrypt it locally using the same Teams key. |
| 89 | + |
| 90 | +This ensures that only members of your Teams organization can access the private key. |
0 commit comments