apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: example-go-template
  title: Example Go template
  description: An example template for the scaffolder that creates a simple go service
spec:
  owner: user:guest
  type: service

  parameters:
    - title: Fill in some steps
      required:
        - name
      properties:
        name:
          title: Name
          type: string
          description: Unique name of the component
          ui:autofocus: true

  steps:
    - id: fetch-template
      name: Fetch Template
      action: fetch:template
      input:
        url: ./skeleton
        targetPath: ./skeleton
        values:
          name: ${{ parameters.name }}

    - id: publish
      name: Publish to Gitea
      action: publish:gitea
      input:
        repoUrl: gitea.factory.c-one-infra.de:443/?repo=${{parameters.name}}
        description: This is the repository for ${{ parameters.name }}
        sourcePath: ./skeleton
        defaultBranch: main

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

  output:
    links:
      - title: Repository
        url: ${{ steps['publish'].output.remoteUrl }}
      - title: Open in Catalog
        icon: catalog
        entityRef: ${{ steps['register'].output.entityRef }}
