List Workspace Contents

Action ID: fs:readdir
NPM Package:

@backstage/plugin-scaffolder-backend

Description

Reads files and directories from the workspace

Input Schema

PropertyTypeDescriptionRequired
pathsarray-
recursiveboolean-

Output Schema

PropertyTypeDescriptionRequired
filesarray-
foldersarray-

Usage Examples

List top-level files and folders after fetching a template

Use this to quickly inspect what a template generated in the workspace. It fetches files with fetch:template, lists only immediate children with fs:readdir, then prints the results with debug:log.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: ./skeletons/node-service
      targetPath: ./
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.owner }}
        packageManager: pnpm

  - id: list-top-level
    action: fs:readdir
    input:
      paths:
        - ./
        - ./packages
      recursive: false

  - id: log-summary
    action: debug:log
    input:
      message: |
        Generated files: ${{ steps.list-top-level.output.files }}
        Generated folders: ${{ steps.list-top-level.output.folders }}

Recursively scan service and infra directories for post-processing

Use this to capture all files created for a specific service and its infrastructure. It fetches a monorepo template with fetch:template, recursively lists contents under the service and infra paths, then logs the inventory with debug:log.

Copy
steps:
  - id: fetch-monorepo
    action: fetch:template
    input:
      url: ./skeletons/monorepo
      targetPath: ./
      values:
        repoName: ${{ parameters.repoName }}
        serviceId: ${{ parameters.serviceId }}
        owner: ${{ parameters.owner }}

  - id: scan-service-and-infra
    action: fs:readdir
    input:
      paths:
        - ./services/${{ parameters.serviceId }}
        - ./infra/k8s
      recursive: true

  - id: log-inventory
    action: debug:log
    input:
      message: |
        Recursive files: ${{ steps.scan-service-and-infra.output.files }}
        Recursive folders: ${{ steps.scan-service-and-infra.output.folders }}

Other actions in @backstage/plugin-scaffolder-backend