Introduction
Node-RED Projects is a feature of Node-RED that provides version control for your flows. It allows users to manage flows via GitHub repositories which makes it easier to track changes and collaborate with coworkers.
First, you will learn how to enable and setup Node-RED Projects, followed by a demonstration of its usage in the second step.
Prerequisites
ctrlX CORE with:
Node-RED (Version 3.6.0 or higher for full functionality)
Internet Access
Setup Node-RED Projects for the ctrlX CORE
To setup Node-RED Projects for the ctrlX CORE, a series of steps has to be followed:
1) Enable Node-RED Projects
Navigate to "Manage App Data" -> "Node-RED configuration" -> "projects_enabled".
Set "projects_enabled" to "true" and click "Save".
If the file does not exist, simply create it by clicking on the plus in the top right corner, name it "projects_enabled" and set it to "true".
In order to make the changes be effective, Node-RED has to be restarted once.
2) Add a Remote Connection
You can choose between either an SSH-Remote-Connection or an HTTPS-Remote-Connection. In general, the use of the SSH-Remote Connection is recommended.
2.1 SSH Remote (Node RED Version > 3.6.0)
Open the GitHub repository that you want to connect with and copy the SSH URL.
Go to Node-RED, open/create a project and add the URL as remote connection. The SSH-URL has to be modified to ssh://[email protected]/Username/Projectname.git
2.2 HTTPS Remote (Node RED Version > 3.2.1)
The workflow is quite similar to 2.1. Just copy the HTTPS-URL instead of the SSH-URL.
Furthermore, you have to add a personal access token to your GitHub Account:
Open GitHub and Navigate to "Settings" -> "Developer Settings" (at the very bottom) and generate a Classic Token.
Name the token and give it all necessary rights (You can just fill all of the boxes). Then click "Generate Token" and store the token at a secure location (f.e. KeyPass).
When using NodeRED Projects, following field will pop up, in which you will have to insert the token:
3) Generate an RSA Key and add it to your GitHub Account
Open the ctrlX Web-Interface and navigate to "Settings" -> "Certificates & Keys" -> "Node-RED" -> "Keys"
Next, you need to copy the correct key from Node-RED. Therefore, open Node-RED and Navigate to "Settings" -> "Git config" -> "SSH Keys" and copy the newly created key.
Open your Github Account and navigate to "Settings" -> "SSH and GPG Keys"
Click on "New SSH Key" and paste the newly generated key into your GitHub account.
Use all Node-RED Projects functionalities
Once the previous steps are completed, you are good to go to make full use of the Node-RED Projects functionalities. A brief the description of the 4 main functionalities (Clone, Commit, Push, Pull) will be given in the following.
1) Clone a GitHub Repository into Node-RED
Copy the SSH URL of your GitHub repository again and follow the steps displayed on the screenshot to clone the repository.
2) Commit your changes
If you made some changes in your flow, you can commit them afterwards. Therefore, first hit deploy, then stage your changes and commit them with a corresponding commit message.
3) Push your changes into GitHub
To make your commits visible in your Online GitHub-repository, you have to push them. Therefore, open your Commit History, select a branch and click the small button in the top right corner, select the correct branch and click push.
If you open your GitHub repository, you should now see all the changes you've made.
4) Pull changes from your repository
If some coworker made changes on the repository that you do not have, you can pull them. Therefore, follow the same steps as in 3), but click on "Pull" instead.