actions/synchronize
Some checks failed
/ alpine (push) Successful in 45s
/ debian (push) Failing after 1m3s
/ ubuntu (push) Failing after 1m4s
/ arch (push) Successful in 1m42s
/ opensuse (push) Successful in 2m27s
/ fedora (push) Successful in 9m32s
/ alma (push) Failing after 1m40s
/ rocky (push) Failing after 2m28s

This commit is contained in:
Marc Beninca 2024-10-15 19:41:40 +02:00
parent f9c8cbc59e
commit 588bf5c6c4
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 51 additions and 8 deletions

View file

@ -10,7 +10,7 @@ from rwx import fs
from rwx.log import stream as log
from rwx.ps import run
from spcd import cmd
from spcd import act, cmd
from spcd.ci import project, projects
from spcd.shell import env
from spcd.util import browse, cat, split, step
@ -131,12 +131,17 @@ def main(main_file: Path) -> None:
path, *arguments = sys.argv
name = Path(path).name
if name == "__main__.py":
list_environment_variables()
clone_project_branch()
set_ssh()
install_actions(main_file)
install_commands(main_file)
install_python_packages()
if arguments:
name, *arguments = arguments
f = getattr(act, name)
f(*arguments)
else:
list_environment_variables()
clone_project_branch()
set_ssh()
install_actions(main_file)
install_commands(main_file)
install_python_packages()
else:
f = getattr(cmd, name.replace("-", "_"))
f(*arguments)

38
spcd/act.py Normal file
View file

@ -0,0 +1,38 @@
"""Actions available for workflows."""
import os
from pathlib import Path
from rwx import ps
from spcd.ci import project, projects
from spcd.shell import env
def synchronize(
source: str | None = None, target: str | None = None
) -> None:
"""Synchronize output towards a target.
:param source: where to deploy from
:type source: str | None
:param target: where to deploy to
:type target: str | None
"""
if not target:
user = "cd"
host = env.SPCD_PROJECT_PATH
root = (
Path(os.sep) / user / projects.group / project.name / project.branch
)
target = f"{user}@{host}:{root}"
if not source:
source = "out"
ps.run(
"rsync",
"--archive",
"--delete-before",
"--verbose",
f"{source}/",
f"{target}/",
)

View file

@ -5,4 +5,4 @@ inputs:
runs:
using: composite
steps:
- run: echo "synchronize"
- run: python3 -m "spcd" "synchronize"