Using automation to update Scripts within Switch

Post Reply
RipTechDev
Newbie
Posts: 1
Joined: Tue Aug 08, 2023 7:21 pm

Using automation to update Scripts within Switch

Post by RipTechDev »

We would like to know if its possible to update our Switch scripts programmatically as part of our CI/CD pipeline.
The process we would like to implement is that as part of our normal CD GitHub actions workflow, we transpile our scripts using the SwitchScriptTool tool, then update the .sscript files on our VM hosting Switch. This would allow us to update our scripts without manual intervention.
We are trying to avoid any manual intervention on the Switch side of things when our scripts our updated. Ideally, we build and deploy in CI and then Switch automatically gets updated.
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Re: Using automation to update Scripts within Switch

Post by freddyp »

Switch can work with script folders (.sscript file in that folder is 0 bytes and acts only as a placeholder) and with packed scripts (.sscript is the "real" thing).

The usual way of working is that you develop a script using script folders and that you deploy a packed script in production. The advantage of working with a script folder during development is that you can make a change to the code, transpile it and without stopping the flow the new behavior is deployed. The disadvantage of working with a script folder in production is exactly the same: you do not want your production to go down because you made a wrong code change that is immediately picked up your production. So if you use script folders for development and packed scripts in production you can nicely separate the two.

That is if you develop on the production machine! If you have a separate Switch with a developer license you could indeed safely work with script folders in production.

Another thing to consider is that activating a new version of a packed script requires all flows that use the script to be stopped and started.

So, what are your options for your CI/CD pipeline method?

Work with script folders on production and make sure that the scripts are developed elsewhere and that the ones on production are only changed by the automated procedure.

Work with packaged scripts, but this involves stopping all flows (that can be done by the Switch REST API), replacing the scripts and starting all flows again. That could all be part of the automation. This option will be a bit more work.

And a final thing to consider: if you change the properties of your scripts they have to be reloaded. This is probably a moot point because if you change the properties it inevitably means that you have to make changes to the flow design anyhow, but it is worth knowing.
mkayyyy
Member
Posts: 80
Joined: Mon Nov 21, 2016 6:31 pm
Location: UK

Re: Using automation to update Scripts within Switch

Post by mkayyyy »

There isn't really a perfect CI/CD pipleline for Switch Scripts that I've found as of yet. What we currently use is the same as what was outlined on this thread and works pretty well for us at the moment: viewtopic.php?p=12389#p12389
patej
Member
Posts: 79
Joined: Sun Nov 25, 2012 12:15 pm

Re: Using automation to update Scripts within Switch

Post by patej »

I just posted an update to our process outline @mkayyyy referred to because we've made a couple of changes in the past year: viewtopic.php?p=15570#p15570
Still not perfect, but easier than before.
Post Reply