template action expose rendered file in result output
This commit is contained in:
parent
385aef856e
commit
621b0555d2
|
@ -31,13 +31,15 @@ class TemplateAction(Action):
|
||||||
def execute(self, **kwargs):
|
def execute(self, **kwargs):
|
||||||
workspace = kwargs.get("workspace")
|
workspace = kwargs.get("workspace")
|
||||||
arguments = kwargs.get("arguments")
|
arguments = kwargs.get("arguments")
|
||||||
|
execution = kwargs.get("execution")
|
||||||
|
|
||||||
source_path = os.path.join(os.getcwd(), self.parameters.src)
|
source_path = os.path.join(os.getcwd(), self.parameters.src)
|
||||||
|
|
||||||
assert os.path.exists(source_path), "Source template does not exist"
|
assert os.path.exists(source_path), "Source template does not exist"
|
||||||
|
|
||||||
template = Template(open(source_path, "r").read())
|
template = Template(open(source_path, "r").read())
|
||||||
|
rendered = template.render(current_execution=execution, **arguments)
|
||||||
with open(os.path.join(workspace.path, self.parameters.dest), "w") as handler:
|
with open(os.path.join(workspace.path, self.parameters.dest), "w") as handler:
|
||||||
handler.write(template.render(**arguments))
|
handler.write(rendered)
|
||||||
|
|
||||||
return Result(success=True)
|
return Result(success=True, output=rendered)
|
||||||
|
|
Reference in New Issue