NodeRed - GitHUB Automation Help

Hi... I made a script that downloads files from Github and then I have scheduled a cron job for each of my scripts and everything is running fine.

But then the problem is if I add any new file to my Github. It is downloaded onto my local server but unfortunately I will have to come to NodeRed again and add blocks to run that newly downloaded script.

Is there any way to automate this process ? where in nodered directly fetches the newly downloaded file and runs it ?

Possibly better to use git to locally clone the repo. change the cron job to do a git pull then all the files will be local and you can use a simple script or one of the filing system nodes to walk through them.

can u pls elaborate a lil ? I don't understand how NodeRed is automatically fetching the script and running it ? as per ur solution

Do you know about git?

With it you can clone a github repository to a local folder. You do that by hand just once.

Then, you can update it with a git pull command. Any new or changed files will be pulled down and any deleted files removed. You can run the pull command from an exec node.

Then you can run any script in the repo. To run them all, there are nodes that will get all of the files in a folder and you can pass each file name to an exec node to run them.

All tasks u mentioned were already automated by me. The part I want is as soon as a new script is downloaded through git pull NOdeRed should automatically create a flow(without us creating a flow in NodeRed ) to run this newly downloaded script. That is my scope

You can use a Watch node to recognise that there is a new file, then add it to the Cron configuration automatically. No need for any new flow.

But is there any way that NodeRed can create a flow automatically as soon as the "watch node" detects new file ?

I believe that you can use the Admin API to do that, but it is much better, unless you have an unusual requirement, to make a general purpose flow which uses data to decide what to do, so it is not necessary to make a new flow. Please explain in more detail what would be in the new flow that you would create.

My whole idea is to completely automate the process. Here's the idea.

When I commit a file to Github, Node red should automatically clone that repo on to the local server ( DONE)

Next step is that Node Red should automatically create a flow to run the newly downloaded file.

Hence the whole process is automated. By just committing my files to github I will be automatically run them and produce the output.

The question is why do you need to create a flow to run the file? What is involved in 'running' the file?

Just wanted it to be in flowchart representation. But to be honest I don't need the flow to be created.

Sorry, I have no idea what you want to do.

If you want to do that, you will need to look at GitHub actions and get GitHub to connect to Node-RED when the repo updates.

Really, you are looking in the wrong place. You need something like Azure Logic Apps or Microsoft Power Automate, possibly even IFTTT so that a GitHub action can connect to something that updates data that in turn updates your flowchart.

Node-RED can do it but this isn't an especially simple task to set up and it needs a fair bit of knowledge to get the different tools to talk to each other.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.