Rename Files and Directories

Action ID: fs:rename
NPM Package:

@backstage/plugin-scaffolder-backend

Description

Renames files and directories within the workspace

Input Schema

PropertyTypeDescriptionRequired
filesarrayA list of file and directory names that will be renamed

Output Schema

No output schema defined for this action.

Usage Examples

Rename template directories and common files after fetching

Use this to rename a scaffolded service directory and normalize common files like README and env files. It runs after fetch:template and before publish:github.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/example-org/software-templates/node-service
      targetPath: .
      values:
        name: ${{ parameters.serviceName }}
        owner: ${{ parameters.owner }}

  - id: rename-files
    action: fs:rename
    input:
      files:
        - from: packages/service
          to: services/${{ parameters.serviceName }}
        - from: README.template.md
          to: README.md
        - from: .env.example
          to: .env

  - id: publish
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}
      defaultBranch: main

Move and rename nested paths for environment-specific setup

Use this to reorganize nested directories and rename manifests based on environment input. It fits between fetch:template and a publish step like publish:github.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/example-org/software-templates/k8s-service
      targetPath: .
      values:
        appId: ${{ parameters.appId }}
        env: ${{ parameters.environment }}

  - id: move-and-rename
    action: fs:rename
    input:
      files:
        - from: apps/web
          to: apps/${{ parameters.appId }}
        - from: k8s/deployment.yaml
          to: deploy/${{ parameters.environment }}/deployment.yaml
        - from: k8s/service.yaml
          to: deploy/${{ parameters.environment }}/service.yaml
        - from: charts/app
          to: charts/${{ parameters.appId }}

  - id: publish
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.repoName }}

Other actions in @backstage/plugin-scaffolder-backend