Secrets in NBdev CI
A guide for showing how to add secrets and keys to NBdev CI
Intro
Goal: The goal of this article is to walk through how to store encrypted secrets in Github Actions for the purpose of using these for NBDev's CI. From this post you will see how to add secrets to any Github Action, but the focus of this post is on NBDev Continuous Integration
What's Included in this post: The minimum needed to get secrets stored in a specific repositories Github Action.
Where can I find something more detailed on this topic? Github Docs. This guide is mostly a subset of information that in on that page.
Background
What is NBDEV? NBDev is a development environment for python. It allows for "Real" development in jupyter notebooks that will automatically build documentation, run tests, and build the library based on those notebooks. All code, tests, and documentation is written in Jupyter Notebooks and the rest is automated to convert it into the appropriate formats.
What is a Github Action? A github action is a piece of code that you run on a specific trigger. For example, when updates are committed to Github, NBDev runs all the notebooks (which includes tests) to ensure that all tests still pass.
Follow instructions for either the "Create Encrypted Secrets for Repo" section for individual permissions or "Create Encrypted Secrets for Organization" for organization level secrets. Further sections are the same regardless of which approach you take.
In your Repository go to Settings -> Secrets -> Add New Secret and add your secret
go to Settings -> Secrets -> Add New Secret and add your secret.
You can update which repositories have access to the secret by visiting the Settings -> Secrets page (Same place you created the secret at above) and selecting "Update"
Select "Workflow File and then the edit Symbol. This will give us the main workflow file in our repository for this action and allow us to edit it.
Add our "SUPERSECRET" to the environment in the "Run Tests" section. We will do this by adding a little bit of code which will store our secret "SUPERSECRET" that we created in the repo earlier, and put that as an environment variable "SUPER_SECRET".
Then you can commit this change right in your browser