Templates variables into file and directory names and content in the action context workspace.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| values | object | - | |
| replace | boolean | - | |
| sourcePath | string | - | |
| targetPath | string | - | |
| cookiecutterCompat | boolean | - | |
| copyWithoutTemplating | array | - | |
| templateFileExtension | string | - |
Output Schema
Usage Examples
Render a service skeleton into a target folder
Templates the files in a skeleton directory using parameters from the form and writes the result to a service-specific folder. Use when you have a workspace skeleton and want to generate a new service instance.
steps:
- id: render-service
action: workspace:template
input:
sourcePath: ./skeleton
targetPath: ./services/${{ parameters.name }}
values:
name: ${{ parameters.name }}
owner: ${{ parameters.owner }}
description: ${{ parameters.description }}
port: ${{ parameters.port }}
copyWithoutTemplating:
- .git/** # keep any VCS metadata untouched if present
- assets/** # static assets
- "**/*.png" # binaries
templateFileExtension: .njkMigrate a Cookiecutter template with compatibility mode
Processes a Cookiecutter-style template in the workspace and outputs a rendered project. Use when converting an existing Cookiecutter template.
steps:
- id: cookiecutter-compat
action: workspace:template
input:
sourcePath: ./cookiecutter-template
targetPath: ./generated/${{ parameters.project_slug }}
values:
project_slug: ${{ parameters.project_slug }}
module_name: ${{ parameters.moduleName }}
author_name: ${{ parameters.author }}
license: ${{ parameters.license }}
copyWithoutTemplating:
- hooks/** # cookiecutter hook scripts
- "**/*.ico"
cookiecutterCompat: trueRe-render into an existing target with replace enabled
Overwrites an existing generated folder with updated values. Use when re-running scaffolding to refresh files.
steps:
- id: rerender-overwrite
action: workspace:template
input:
sourcePath: ./templates/service
targetPath: ./output/${{ parameters.serviceId }}
values:
serviceId: ${{ parameters.serviceId }}
image: ${{ parameters.containerImage }}
replicas: ${{ parameters.replicas }}
copyWithoutTemplating:
- node_modules/** # skip templating third-party code
- ".git/**"
replace: trueRender only Handlebars files and leave others untouched
Limits templating to .hbs files so other files are copied as-is. Use when only specific files need variable substitution.
steps:
- id: render-hbs-only
action: workspace:template
input:
sourcePath: ./handlebars-template
targetPath: ./services/${{ parameters.name }}
values:
name: ${{ parameters.name }}
org: ${{ parameters.org }}
ci: ${{ parameters.ciProvider }}
copyWithoutTemplating:
- public/** # static site content
- "**/*.svg"
templateFileExtension: .hbsGenerate service docs from a docs template
Renders a docs template into a service docs folder while skipping images. Use when producing README and mkdocs config alongside a service.
steps:
- id: render-docs
action: workspace:template
input:
sourcePath: ./docs-template
targetPath: ./services/${{ parameters.name }}/docs
values:
docTitle: ${{ parameters.name }} Service
serviceName: ${{ parameters.name }}
owner: ${{ parameters.owner }}
backstageEntityRef: ${{ parameters.owner }}/service/${{ parameters.name }}
copyWithoutTemplating:
- images/**
- "**/*.gif"
templateFileExtension: .njk