Skip to content

Commit 7c25a8e

Browse files
Merge pull request #2 from PatAKnight/bulk-import-simple-template
Bulk import simple template
2 parents 5226f67 + ad8667f commit 7c25a8e

File tree

25 files changed

+56
-3394
lines changed

25 files changed

+56
-3394
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
apiVersion: backstage.io/v1alpha1
22
kind: Component
33
metadata:
4-
name: ${{ values.name | dump }}
4+
name: ${{ values.name }}
5+
annotations:
6+
github.com/project-slug: ${{ values.organization }}/${{ values.name }}
57
spec:
6-
type: service
7-
owner: user:guest
8-
lifecycle: experimental
8+
type: other
9+
owner: ${{ values.organization }}
10+
lifecycle: unknown

workspaces/bulk-import/examples/template/content/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

workspaces/bulk-import/examples/template/content/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

workspaces/bulk-import/examples/template/create-pr-with-catalog-info.yaml

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,36 @@ spec:
1818
type: string
1919
title: Repository URL (Backstage format)
2020
description: 'e.g. github.com?owner=Org&repo=repoName'
21+
organization:
22+
type: string
23+
title: Owner of the Repository
24+
branchName:
25+
type: string
26+
title: The branch to add the catalog entity to
27+
targetBranchName:
28+
type: string
29+
title: The branch to target the PR to
30+
name:
31+
type: string
32+
title: Name of the repository
2133

2234
steps:
23-
- id: parse-query
24-
name: Parse GitHub Query
25-
action: roadiehq:utils:jsonata
26-
input:
27-
data: ${{ parameters.repoUrl }}
28-
expression: |
29-
{
30-
"owner": $substringAfter($substringBefore($, "&repo="), "?owner="),
31-
"repo": $substringAfter($, "&repo=")
32-
}
33-
34-
- id: get-default-branch
35-
name: Get Default Branch
36-
action: git:get-default-repository-branch
37-
input:
38-
repoUrl: ${{ parameters.repoUrl }}
39-
40-
- id: createCatalogInfo
41-
name: Prepare catalog-info.yaml
42-
action: roadiehq:utils:fs:write
35+
- id: fetch-base
36+
name: Fetch Base
37+
action: fetch:template
4338
input:
44-
path: ./catalog-info.yaml
45-
content: |
46-
apiVersion: backstage.io/v1alpha1
47-
kind: Component
48-
metadata:
49-
name: ${{ steps['parse-query'].output.result.repo }}
50-
annotations:
51-
github.com/project-slug: ${{ steps['parse-query'].output.result.owner }}/${{ steps['parse-query'].output.result.repo }}
52-
spec:
53-
type: other
54-
lifecycle: unknown
55-
owner: user:default/test-user
39+
url: ./content
40+
values:
41+
name: ${{ parameters.name }}
42+
organization: ${{ parameters.organization }}
5643

5744
- id: publish
5845
name: Create PR to add catalog-info.yaml
5946
action: publish:github:pull-request
6047
input:
6148
repoUrl: ${{ parameters.repoUrl }}
62-
branchName: add-catalog-info-${{ steps['parse-query'].output.result.repo }}
63-
targetBranchName: ${{ steps['get-default-branch'].output.defaultBranch }}
49+
branchName: ${{ parameters.branchName }}
50+
targetBranchName: ${{ parameters.targetBranchName }}
6451
title: 'Add catalog-info.yaml'
6552
description: 'This PR adds a default catalog-info.yaml for Backstage.'
6653

@@ -69,4 +56,4 @@ spec:
6956
action: catalog:register
7057
input:
7158
optional: true
72-
repoContentsUrl: https://github.com/${{ steps['parse-query'].output.result.owner }}/${{ steps['parse-query'].output.result.repo }}/blob/${{ steps['get-default-branch'].output.defaultBranch }}/catalog-info.yaml
59+
repoContentsUrl: https://github.com/${{ parameters.organization }}/${{ parameters.name }}/blob/${{ parameters.branchName }}/catalog-info.yaml

workspaces/bulk-import/examples/template/get-default-branch.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

workspaces/bulk-import/examples/template/import-components-from-existing-repo.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

workspaces/bulk-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": "18 || 20"
77
},
88
"scripts": {
9-
"start": "backstage-cli repo start",
9+
"start": "NODE_OPTIONS=--no-node-snapshot backstage-cli repo start",
1010
"tsc": "tsc",
1111
"tsc:full": "tsc --skipLibCheck true --incremental false",
1212
"build:all": "backstage-cli repo build --all",

workspaces/bulk-import/packages/backend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
"@backstage/plugin-search-backend-node": "^1.3.14",
4646
"@backstage/plugin-techdocs-backend": "^2.0.5",
4747
"@red-hat-developer-hub/backstage-plugin-bulk-import-backend": "workspace:^",
48-
"@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-bulk-get-git-default-branch": "workspace:^",
49-
"@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-catalog-register-with-events": "workspace:^",
5048
"@roadiehq/scaffolder-backend-module-utils": "^3.6.0",
5149
"app": "link:../app",
5250
"better-sqlite3": "^9.0.0",

workspaces/bulk-import/packages/backend/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,4 @@ backend.add(
6464
);
6565
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
6666
backend.add(import('@roadiehq/scaffolder-backend-module-utils'));
67-
backend.add(
68-
import(
69-
'@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-bulk-get-git-default-branch'
70-
),
71-
);
72-
backend.add(
73-
import(
74-
'@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-catalog-register-with-events'
75-
),
76-
);
7767
backend.start();

workspaces/bulk-import/plugins/bulk-import-backend/src/service/handlers/import/execute-template.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ export const createTaskImportJobs = async (
297297
const normalizedUrl = `${new URL(importReq.repository.url).hostname}?owner=${owner}&repo=${repoName}`;
298298

299299
const scaffolderOptions = {
300+
name: repoName,
301+
organization: owner,
300302
repoUrl: normalizedUrl,
303+
branchName: `bulk-import-catalog-entity`,
304+
targetBranchName: importReq.repository.defaultBranch,
301305
};
302306
const { taskId, status, createdAt } =
303307
await executeTask(scaffolderOptions);

0 commit comments

Comments
 (0)