Write Catalog Info File

Action ID: catalog:write
NPM Package:

@backstage/plugin-scaffolder-backend

Description

Writes the catalog-info.yaml for your template

Input Schema

PropertyTypeDescriptionRequired
entityobject-
filePathstring-

Output Schema

No output schema defined for this action.

Usage Examples

Write a Component catalog-info.yaml at the repo root

This writes a Component entity to catalog-info.yaml in the repository root. Use when creating a service that will be published to GitHub and registered in Backstage. Shown with fetch:template, publish:github, and catalog:register.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: ./skeleton

  - id: write-catalog
    action: catalog:write
    input:
      filePath: catalog-info.yaml
      entity:
        apiVersion: backstage.io/v1alpha1
        kind: Component
        metadata:
          name: ${{ parameters.componentId }}
          description: Backend service for processing payments
          tags:
            - node
            - payments
          annotations:
            github.com/project-slug: ${{ parameters.repoOwner }}/${{ parameters.repoName }}
            backstage.io/techdocs-ref: dir:.
        spec:
          type: service
          lifecycle: production
          owner: ${{ parameters.owner }}
          system: ${{ parameters.system }}

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

  - id: register-in-catalog
    action: catalog:register
    input:
      repoContentsUrl: ${{ steps['publish-repo'].output.repoContentsUrl }}
      catalogInfoPath: /catalog-info.yaml

Write a catalog-info.yaml for a monorepo package

This writes a Component entity to a nested path in a monorepo. Use when scaffolding packages under packages/ and registering them individually. Shown with fetch:template, publish:github, and catalog:register.

Copy
steps:
  - id: fetch-package
    action: fetch:template
    input:
      url: ./skeleton-package

  - id: write-catalog-nested
    action: catalog:write
    input:
      filePath: packages/${{ parameters.packageName }}/catalog-info.yaml
      entity:
        apiVersion: backstage.io/v1alpha1
        kind: Component
        metadata:
          name: ${{ parameters.packageName }}
          description: Shared TypeScript utilities for web clients
          tags:
            - typescript
            - library
          annotations:
            github.com/project-slug: ${{ parameters.repoOwner }}/${{ parameters.repoName }}
        spec:
          type: library
          lifecycle: experimental
          owner: ${{ parameters.owner }}
          system: ${{ parameters.system }}
          subcomponentOf: component:default/${{ parameters.parentComponentId }}
          dependsOn:
            - resource:default/redis
            - component:default/shared-ui

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

  - id: register-package
    action: catalog:register
    input:
      repoContentsUrl: ${{ steps['publish-monorepo'].output.repoContentsUrl }}
      catalogInfoPath: /packages/${{ parameters.packageName }}/catalog-info.yaml

Other actions in @backstage/plugin-scaffolder-backend