Page 1 of 1

Using automation to update Scripts within Switch

Posted: Wed Aug 09, 2023 9:08 pm
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.

Re: Using automation to update Scripts within Switch

Posted: Thu Aug 10, 2023 8:34 pm
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.

Re: Using automation to update Scripts within Switch

Posted: Fri Aug 18, 2023 1:35 pm
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

Re: Using automation to update Scripts within Switch

Posted: Fri Sep 08, 2023 1:42 pm
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.