-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathtemplate.yaml
More file actions
147 lines (141 loc) · 5.45 KB
/
template.yaml
File metadata and controls
147 lines (141 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: create-frontend-plugin
title: Create Frontend Plugin Template
description: Template for the scaffolder that creates a frontend plugin skeleton
annotations:
backstage.io/techdocs-ref: dir:.
tags:
- frontend-plugin
- backstage-plugin
spec:
owner: red-hat-developer-hub-authors
system: red-hat-developer-hub
type: plugin
# These parameters are used to generate the input form in the frontend, and are
# used to gather input data for the execution of the template.
parameters:
- title: Provide some information
required:
- plugin_id
- owner
properties:
plugin_id:
title: Plugin ID
type: string
pattern: '^[a-z0-9-]*[a-z0-9]$'
description: Unique ID of the plugin.
ui:help: Plugin IDs must be lowercase and contain only letters, digits, and dashes.
ui:autofocus: true
description:
title: Description
type: string
description: Help others understand what this component is for
owner:
title: Owner
type: string
ui:field: EntityPicker
ui:options:
catalogFilter:
kind:
- Group
- User
- title: Choose a location
required:
- repoUrl
properties:
repoUrl:
title: Repository Location
type: string
ui:field: RepoUrlPicker
ui:options:
allowedHosts:
- github.com
pluginLocation:
type: string
title: Where to publish this new plugin?
ui:widget: radio
default: Create a new repository within the specified organization
enum:
- Submit a pull request to the same repository
- Create a new repository within the specified organization
dependencies:
pluginLocation:
allOf:
- if:
properties:
pluginLocation:
const: Submit a pull request to the same repository
then:
properties:
branchName:
title: Branch Name
type: string
description: The name for the branch
default: ''
targetBranchName:
title: Target Branch Name
type: string
description: The target branch name of the merge request
default: ''
# You can use additional fields of parameters within conditional parameters such as required.
required:
- branchName
- targetBranchName
# These steps are executed in the scaffolder backend, using data that we gathered
# via the parameters above.
steps:
# Each step executes an action
- id: template
name: Fetch Skeleton + Template
action: fetch:template
input:
url: ./skeleton
values:
plugin_id: ${{ parameters.plugin_id }}
repoUrl: ${{ parameters.repoUrl | parseRepoUrl }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
repoName: ${{ (parameters.repoUrl | parseRepoUrl).repo }}
orgName: ${{ (parameters.repoUrl | parseRepoUrl).owner }}
# This step publishes the contents of the working directory to GitHub if it is a new repository.
- id: publish
name: Publish the frontend plugin skeleton in a new repository
if: ${{ parameters.pluginLocation === 'Create a new repository within the specified organization' }}
action: publish:github
input:
allowedHosts: ['github.com']
description: This is ${{ parameters.plugin_id }} frontend plugin.
repoUrl: ${{ parameters.repoUrl }}
sourcePath: plugins/${{parameters.plugin_id}}
# This step creates a pull request with the contents of the working directory.
- id: publishGithub
name: Create pull request with the frontend plugin skeleton
if: ${{ parameters.pluginLocation === 'Submit a pull request to the same repository' }}
action: publish:github:pull-request
input:
repoUrl: ${{ parameters.repoUrl }}
branchName: ${{ parameters.branchName }}
targetBranchName: ${{ parameters.targetBranchName }}
title: Create frontend plugin ${{ parameters.plugin_id }}
description: This pull request creates the skeleton for your frontend plugin
# This step registers the component if the contents are being published to a new repository
- id: register
name: Registering the Catalog Info Component
if: ${{ parameters.pluginLocation === 'Create a new repository within the specified organization' }}
action: catalog:register
input:
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
catalogInfoPath: /catalog-info.yaml
# Outputs are displayed to the user after a successful execution of the template.
output:
links:
- title: View Plugin
url: ${{ steps.publish.output.remoteUrl }}
- title: View Pull Request
url: ${{ steps.publishGithub.output.remoteUrl }}
- title: Open the Catalog Info Component
if: ${{ parameters.pluginLocation === 'Create a new repository within the specified organization' }}
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}