|
| 1 | +apiVersion: scaffolder.backstage.io/v1beta3 |
| 2 | +# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template |
| 3 | +kind: Template |
| 4 | +metadata: |
| 5 | + name: example-nodejs-template |
| 6 | + title: Example Node.js Template |
| 7 | + description: An example template for the scaffolder that creates a simple Node.js service |
| 8 | +spec: |
| 9 | + owner: user:guest |
| 10 | + type: service |
| 11 | + |
| 12 | + # These parameters are used to generate the input form in the frontend, and are |
| 13 | + # used to gather input data for the execution of the template. |
| 14 | + parameters: |
| 15 | + - title: Fill in some steps |
| 16 | + required: |
| 17 | + - name |
| 18 | + properties: |
| 19 | + name: |
| 20 | + title: Name |
| 21 | + type: string |
| 22 | + description: Unique name of the component |
| 23 | + ui:autofocus: true |
| 24 | + ui:options: |
| 25 | + rows: 5 |
| 26 | + - title: Choose a location |
| 27 | + required: |
| 28 | + - repoUrl |
| 29 | + properties: |
| 30 | + repoUrl: |
| 31 | + title: Repository Location |
| 32 | + type: string |
| 33 | + ui:field: RepoUrlPicker |
| 34 | + ui:options: |
| 35 | + allowedHosts: |
| 36 | + - github.com |
| 37 | + |
| 38 | + # These steps are executed in the scaffolder backend, using data that we gathered |
| 39 | + # via the parameters above. |
| 40 | + steps: |
| 41 | + # Each step executes an action, in this case one templates files into the working directory. |
| 42 | + - id: fetch-base |
| 43 | + name: Fetch Base |
| 44 | + action: fetch:template |
| 45 | + input: |
| 46 | + url: ./content |
| 47 | + values: |
| 48 | + name: ${{ parameters.name }} |
| 49 | + |
| 50 | + # This step publishes the contents of the working directory to GitHub. |
| 51 | + - id: publish |
| 52 | + name: Publish |
| 53 | + action: publish:github |
| 54 | + input: |
| 55 | + allowedHosts: ['github.com'] |
| 56 | + description: This is ${{ parameters.name }} |
| 57 | + repoUrl: ${{ parameters.repoUrl }} |
| 58 | + |
| 59 | + # The final step is to register our new component in the catalog. |
| 60 | + - id: register |
| 61 | + name: Register |
| 62 | + action: catalog:register |
| 63 | + input: |
| 64 | + repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }} |
| 65 | + catalogInfoPath: '/catalog-info.yaml' |
| 66 | + |
| 67 | + # Outputs are displayed to the user after a successful execution of the template. |
| 68 | + output: |
| 69 | + links: |
| 70 | + - title: Repository |
| 71 | + url: ${{ steps['publish'].output.remoteUrl }} |
| 72 | + - title: Open in catalog |
| 73 | + icon: catalog |
| 74 | + entityRef: ${{ steps['register'].output.entityRef }} |
0 commit comments