Skip to content

Commit 8cc5161

Browse files
authored
feat(orchestrator): add GitLab among target repos of convertWorkflowToTemplate (#395)
Signed-off-by: Marek Libra <[email protected]>
1 parent dcfe477 commit 8cc5161

File tree

5 files changed

+315
-75
lines changed

5 files changed

+315
-75
lines changed

workspaces/orchestrator/app-config.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ backend:
4343
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir
4444

4545
integrations: {}
46-
# integrations:
47-
# github:
48-
# - token: ${GITHUB_TOKEN}
46+
#integrations:
47+
# github:
48+
# - host: github.com
49+
# token: ${GITHUB_TOKEN}
50+
# gitlab:
51+
# - host: gitlab.com
52+
# token: ${GITLAB_TOKEN}
4953

5054
proxy:
5155
'/quay/api':

workspaces/orchestrator/entities/convertWorkflowToTemplate.yaml

+40-10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ spec:
3434
ui:options:
3535
allowedHosts:
3636
- github.com
37+
- gitlab.com
3738
pluginLocation:
3839
type: string
3940
title: Where to publish this new plugin?
@@ -87,23 +88,48 @@ spec:
8788
repoName: ${{ (parameters.repoUrl | parseRepoUrl).repo }}
8889
orgName: ${{ (parameters.repoUrl | parseRepoUrl).owner }}
8990

90-
# This step publishes the contents of the working directory to GitHub if it is a new repository.
91-
- id: publish
92-
name: Publish the template in a new repository
93-
if: ${{ parameters.pluginLocation === 'Create a new repository within the specified organization' }}
91+
# GitHub: This step publishes the contents of the working directory to GitHub if it is a new repository.
92+
- id: publishGithubRepo
93+
name: Publish the template in a new GitHub repository
94+
if: ${{ (parameters.repoUrl | parseRepoUrl).host === 'github.com' and parameters.pluginLocation === 'Create a new repository within the specified organization' }}
9495
action: publish:github
9596
input:
9697
allowedHosts: ['github.com']
9798
description: This is the template for the ${{ parameters.workflow_id }} workflow.
9899
repoUrl: ${{ parameters.repoUrl }}
99100
sourcePath: templates/${{parameters.workflow_id}}
100101

101-
# This step creates a pull request with the contents of the working directory.
102+
# GitHub: This step creates a pull request with the contents of the working directory.
102103
- id: publishGithub
103-
name: Create pull request with the template
104-
if: ${{ parameters.pluginLocation === 'Submit a pull request to the same repository' }}
104+
name: Create GitHub pull request with the template
105+
if: ${{ (parameters.repoUrl | parseRepoUrl).host === 'github.com' and parameters.pluginLocation === 'Submit a pull request to the same repository' }}
105106
action: publish:github:pull-request
106107
input:
108+
allowedHosts: ['github.com']
109+
repoUrl: ${{ parameters.repoUrl }}
110+
branchName: ${{ parameters.branchName }}
111+
targetBranchName: ${{ parameters.targetBranchName }}
112+
title: Create template ${{ parameters.workflow_id }}
113+
description: This pull request creates template for running a workflow
114+
115+
# GitLab
116+
- id: publishGitlabRepo
117+
name: Publish the template in a new GitLab repository
118+
action: publish:gitlab
119+
if: ${{ (parameters.repoUrl | parseRepoUrl).host === 'gitlab.com' and parameters.pluginLocation === 'Create a new repository within the specified organization' }}
120+
input:
121+
allowedHosts: ['gitlab.com']
122+
description: This is the template for the ${{ parameters.workflow_id }} workflow.
123+
repoUrl: ${{ parameters.repoUrl }}
124+
defaultBranch: main
125+
126+
# GitLab
127+
- id: publishGitlab
128+
name: Create GitLab merge request with the template
129+
action: publish:gitlab:merge-request
130+
if: ${{ (parameters.repoUrl | parseRepoUrl).host === 'gitlab.com' and parameters.pluginLocation === 'Submit a pull request to the same repository' }}
131+
input:
132+
allowedHosts: ['gitlab.com']
107133
repoUrl: ${{ parameters.repoUrl }}
108134
branchName: ${{ parameters.branchName }}
109135
targetBranchName: ${{ parameters.targetBranchName }}
@@ -112,7 +138,11 @@ spec:
112138

113139
output:
114140
links:
115-
- title: View Template
116-
url: ${{ steps.publish.output.remoteUrl }}
117-
- title: View Pull Request
141+
- title: View template repository
142+
url: ${{ steps.publishGithubRepo.output.remoteUrl }}
143+
- title: View template repository
144+
url: ${{ steps.publishGitlabRepo.output.remoteUrl }}
145+
- title: View pull request with the template
118146
url: ${{ steps.publishGithub.output.remoteUrl }}
147+
- title: View merge request with the template
148+
url: ${{ steps.publishGitlab.output.mergeRequestUrl }}

workspaces/orchestrator/packages/backend/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.1",
3131
"@backstage/plugin-auth-node": "^0.5.3",
3232
"@backstage/plugin-catalog-backend": "^1.27.1",
33+
"@backstage/plugin-catalog-backend-module-gitlab": "^0.6.2",
3334
"@backstage/plugin-catalog-backend-module-logs": "^0.1.3",
3435
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "^0.2.1",
3536
"@backstage/plugin-notifications-backend": "^0.4.3",
@@ -40,6 +41,7 @@
4041
"@backstage/plugin-proxy-backend": "^0.5.7",
4142
"@backstage/plugin-scaffolder-backend": "^1.26.2",
4243
"@backstage/plugin-scaffolder-backend-module-github": "^0.5.5",
44+
"@backstage/plugin-scaffolder-backend-module-gitlab": "^0.7.1",
4345
"@backstage/plugin-search-backend": "^1.6.1",
4446
"@backstage/plugin-search-backend-module-catalog": "^0.2.4",
4547
"@backstage/plugin-search-backend-module-pg": "^0.5.37",

workspaces/orchestrator/packages/backend/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ backend.add(import('backstage-plugin-scaffolder-backend-module-orchestrator'));
6464
// for integrating templates with github
6565
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
6666

67+
// for integrating templates with gitlab
68+
backend.add(import('@backstage/plugin-scaffolder-backend-module-gitlab'));
69+
6770
backend.start();

0 commit comments

Comments
 (0)