Wrote a little script that I run in CI/CD that fin...
# show-and-tell
m
Wrote a little script that I run in CI/CD that finds the folder we toss all the Flow files into, then makes a new folder for each one, places the script into it, then `cd`s into it so it can deploy it without uploading our entire repo for every script every time. The main benefit is that adding/editing a new flow is just a one-step process ("put
.py
file into the folder").
Copy code
import os
import subprocess
from pathlib import Path
from shutil import copy

starting_dir = Path(
    "" # Put the folder with the Flows here
).resolve()
all_scripts = list(starting_dir.glob("*.py"))

for script in all_scripts:
    without_extension = str(script).split(".")[0]
    folder = without_extension.split("/")[-1]
    just_script = f"{folder}.py"
    folder_path = Path(starting_dir, folder)
    Path(folder_path).mkdir(parents=True, exist_ok=True)
    new_script_path = Path(folder_path, just_script)
    copy(script, new_script_path)
    os.chdir(folder_path)
    subprocess.run(["python", new_script_path])