Template File Renderer

Action ID: workspace:template:file
NPM Package:

@backstage/plugin-scaffolder-backend

Description

Templates variables into a single workspace file, placing the result into another location in the workspace.

Input Schema

PropertyTypeDescriptionRequired
valuesobject-
replaceboolean-
sourcePathstring-
targetPathstring-
cookiecutterCompatboolean-

Output Schema

No output schema defined for this action.

Usage Examples

Render a README from a Handlebars template

Use this to generate a README.md from a template after you fetch your skeleton with fetch:template. It injects service details from template parameters.

Copy
steps:
  - id: render-readme
    action: workspace:template:file
    input:
      sourcePath: ./.skeleton/README.md.hbs
      targetPath: ./README.md
      values:
        name: ${{ parameters.componentName }}
        owner: ${{ parameters.owner }}
        description: ${{ parameters.description }}
        repoUrl: ${{ parameters.repoUrl }}

Overwrite an environment-specific Kubernetes manifest

Use this to render a Kubernetes Deployment file for a specific environment and overwrite an existing file if present. Helpful when regenerating manifests during updates.

Copy
steps:
  - id: render-k8s-deployment
    action: workspace:template:file
    input:
      sourcePath: ./.skeleton/k8s/deployment.yaml.hbs
      targetPath: ./k8s/deployment-${{ parameters.environment }}.yaml
      replace: true
      values:
        serviceName: ${{ parameters.componentName }}
        image: ghcr.io/acme/${{ parameters.componentName }}:${{ parameters.dockerTag }}
        replicas: ${{ parameters.replicas }}
        port: 8080
        env:
          LOG_LEVEL: info
          FEATURE_X_ENABLED: true

Render a cookiecutter-style template file

Enable cookiecutterCompat when your source template uses cookiecutter syntax. This converts a Jinja-style file into a Markdown guide.

Copy
steps:
  - id: render-cookiecutter-usage
    action: workspace:template:file
    input:
      sourcePath: ./cookiecutter-template/USAGE.md.j2
      targetPath: ./docs/USAGE.md
      cookiecutterCompat: true
      values:
        project_name: ${{ parameters.componentName }}
        module_name: ${{ parameters.moduleName }}
        owner: ${{ parameters.owner }}
        license: ${{ parameters.license }}

Generate a LICENSE without overwriting an existing file

Use replace false to avoid clobbering a LICENSE that may already exist in the repo. The template is chosen dynamically from a license type parameter.

Copy
steps:
  - id: render-license
    action: workspace:template:file
    input:
      sourcePath: ./.skeleton/licenses/${{ parameters.license }}.hbs
      targetPath: ./LICENSE
      replace: false
      values:
        year: 2025
        owner: ${{ parameters.owner }}

Create a CI workflow with branch and runtime matrices

Render a GitHub Actions workflow from a template with matrix values. This is typically done after pulling workflow templates with fetch:plain.

Copy
steps:
  - id: render-ci-workflow
    action: workspace:template:file
    input:
      sourcePath: ./.skeleton/workflows/ci.yml.hbs
      targetPath: ./.github/workflows/${{ parameters.componentName }}-ci.yml
      values:
        serviceName: ${{ parameters.componentName }}
        defaultBranch: ${{ parameters.defaultBranch }}
        releaseBranches:
          - main
          - release/*
        nodeVersions:
          - 18
          - 20
        cacheKey: ${{ parameters.cacheKey }}

Other actions in @backstage/plugin-scaffolder-backend