Delete Files And Directories

Action ID: fs:delete
NPM Package:

@backstage/plugin-scaffolder-backend

Description

Deletes files and directories from the workspace

Input Schema

PropertyTypeDescriptionRequired
filesarrayA list of files and directories that will be deleted

Output Schema

No output schema defined for this action.

Usage Examples

Remove example files after fetching a template

Use this to strip example code and scaffold-only files after pulling a base template with fetch:template and before publishing with publish:github. The deletion runs only when the includeExamples parameter is false.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: https://github.com/acme-org/service-template/archive/main.tar.gz
      targetPath: .
      values:
        name: ${{ parameters.name }}
        owner: ${{ parameters.owner }}

  - id: remove-examples
    if: ${{ not parameters.includeExamples }}
    action: fs:delete
    input:
      files:
        - examples/
        - docs/getting-started.md
        - scripts/dev.sh

  - id: publish
    action: publish:github
    input:
      repoUrl: ${{ parameters.repoUrl }}

Runtime specific cleanup in a monorepo

Use this to remove files that do not apply to the selected runtime after fetching the template with fetch:template. It deletes different sets of files based on a runtime parameter and then publishes with publish:github.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/acme-org/monorepo-template/archive/main.tar.gz
      targetPath: .
      values:
        packageName: ${{ parameters.packageName }}
        runtime: ${{ parameters.runtime }}

  - id: cleanup-for-lambda
    if: ${{ parameters.runtime == 'lambda' }}
    action: fs:delete
    input:
      files:
        - Dockerfile
        - k8s/
        - helm/

  - id: cleanup-for-container
    if: ${{ parameters.runtime == 'container' }}
    action: fs:delete
    input:
      files:
        - serverless.yml
        - infra/serverless/

  - id: remove-placeholder-files
    action: fs:delete
    input:
      files:
        - packages/${{ parameters.packageName }}/__mocks__/
        - packages/${{ parameters.packageName }}/README.placeholder.md

  - id: publish
    action: publish:github
    input:
      repoUrl: ${{ parameters.repoUrl }}

Other actions in @backstage/plugin-scaffolder-backend