apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: xl-cli-with-github
  title: Provision Digital.ai Release/Deploy via YAML from GitHub using xl CLI
  description: The xl command line tool method for provisioning Digital.ai Release and Deploy servers using YAML file
spec:
  owner: default:user/guest
  type: service
  parameters:
    - title:  Select Product
      required:
        - product
      properties:
        product:
          type: string
          enum:
            - xl-release
            - xl-deploy
          default: xl-deploy
        releaseInstance:
          title: Release Instance
          type: string
          description: Release instance to run the command
    - title: Provide information about the GitHub location
      required:
        - githubHost
        - githubOrganization
        - repositoryName
      properties:
        githubHost:
          title: GitHub hostname
          type: string
          description: Use github.com for GitHub Free, Pro, & Team or specify a hostname of your GitHub Enterprise instance.
          default: github.com
        githubOrganization:
          title: GitHub Organization
          type: string
        repositoryName:
          title: Repository name
          type: string
        filePath:
          title: filePath
          type: string
          description: Path to yaml file
  steps:
    - id: debug-log
      name: Log Selected Option
      action: debug:log
      input:
        message: "You selected: ${{ parameters.product }} - ${{ parameters.filePath }} - ${{ parameters.yamlContent }}"
    - id: fetchRepository
      name: Fetch repository
      action: fetch:plain
      input:
        url: https://${{ parameters.githubHost }}/${{ parameters.githubOrganization }}/${{ parameters.repositoryName }}
    - id: xlcliApply
      name: Apply xl-cli
      action: digitalai:xlcli:apply
      input:
        product: ${{ parameters.product }}
        releaseInstance: ${{ parameters.releaseInstance }}
        filePath: ${{ parameters.filePath }} # relative path to yaml file eg: ./app.yaml