@backstage/plugin-scaffolder-backend 0.0.0-nightly-20220718024938 → 0.0.0-nightly-20220722025125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -10
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +20 -0
- package/dist/index.beta.d.ts +20 -0
- package/dist/index.cjs.js +201 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -0
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220722025125
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- eeff5046ae: Updated `publish:gitlab:merge-request` action to allow commit updates and deletes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- fc8a5f797b: Add a `publish:gerrit:review` scaffolder action
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/backend-common@0.0.0-nightly-20220722025125
|
|
14
|
+
- @backstage/integration@0.0.0-nightly-20220722025125
|
|
15
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20220722025125
|
|
16
|
+
- @backstage/plugin-catalog-backend@0.0.0-nightly-20220722025125
|
|
17
|
+
|
|
18
|
+
## 1.4.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- e1a08d872c: Added optional assignee parameter for Gitlab Merge Request action
|
|
23
|
+
- dab9bcf2e7: Add `protectEnforceAdmins` as an option to GitHub publish actions
|
|
7
24
|
- 4baf8a4ece: Update GitLab Merge Request Action to allow source branch to be deleted
|
|
8
25
|
- 91c1d12123: Export experimental `scaffolderCatalogExtension` for the new backend system. This export is not considered stable and should not be used in production.
|
|
26
|
+
- d10ccc2ed1: Introduced audit log message when a new scaffolder task is created
|
|
9
27
|
- 2db07887cb: Added two new scaffolder actions: `github:repo:create` and `github:repo:push`
|
|
10
28
|
|
|
11
29
|
### Patch Changes
|
|
@@ -40,15 +58,15 @@
|
|
|
40
58
|
- 945a27fa6a: Add sourcePath option to publish:gerrit action
|
|
41
59
|
- 1764296a68: Allow to create Gerrit project using default owner
|
|
42
60
|
- Updated dependencies
|
|
43
|
-
- @backstage/backend-plugin-api@0.
|
|
44
|
-
- @backstage/plugin-catalog-backend@
|
|
45
|
-
- @backstage/backend-common@0.
|
|
46
|
-
- @backstage/catalog-model@
|
|
47
|
-
- @backstage/plugin-catalog-node@
|
|
48
|
-
- @backstage/integration@
|
|
49
|
-
- @backstage/catalog-client@
|
|
50
|
-
- @backstage/errors@
|
|
51
|
-
- @backstage/plugin-scaffolder-common@
|
|
61
|
+
- @backstage/backend-plugin-api@0.1.0
|
|
62
|
+
- @backstage/plugin-catalog-backend@1.3.0
|
|
63
|
+
- @backstage/backend-common@0.14.1
|
|
64
|
+
- @backstage/catalog-model@1.1.0
|
|
65
|
+
- @backstage/plugin-catalog-node@1.0.0
|
|
66
|
+
- @backstage/integration@1.2.2
|
|
67
|
+
- @backstage/catalog-client@1.0.4
|
|
68
|
+
- @backstage/errors@1.1.0
|
|
69
|
+
- @backstage/plugin-scaffolder-common@1.1.2
|
|
52
70
|
|
|
53
71
|
## 1.4.0-next.3
|
|
54
72
|
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -303,6 +303,7 @@ repoUrl: string;
|
|
|
303
303
|
description?: string | undefined;
|
|
304
304
|
defaultBranch?: string | undefined;
|
|
305
305
|
protectDefaultBranch?: boolean | undefined;
|
|
306
|
+
protectEnforceAdmins?: boolean | undefined;
|
|
306
307
|
gitCommitMessage?: string | undefined;
|
|
307
308
|
gitAuthorName?: string | undefined;
|
|
308
309
|
gitAuthorEmail?: string | undefined;
|
|
@@ -440,6 +441,22 @@ gitAuthorEmail?: string | undefined;
|
|
|
440
441
|
sourcePath?: string | undefined;
|
|
441
442
|
}>;
|
|
442
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Creates a new action that creates a Gerrit review
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
export declare function createPublishGerritReviewAction(options: {
|
|
449
|
+
integrations: ScmIntegrationRegistry;
|
|
450
|
+
config: Config;
|
|
451
|
+
}): TemplateAction< {
|
|
452
|
+
repoUrl: string;
|
|
453
|
+
branch?: string | undefined;
|
|
454
|
+
sourcePath?: string | undefined;
|
|
455
|
+
gitCommitMessage?: string | undefined;
|
|
456
|
+
gitAuthorName?: string | undefined;
|
|
457
|
+
gitAuthorEmail?: string | undefined;
|
|
458
|
+
}>;
|
|
459
|
+
|
|
443
460
|
/**
|
|
444
461
|
* Creates a new action that initializes a git repository of the content in the workspace
|
|
445
462
|
* and publishes it to GitHub.
|
|
@@ -456,6 +473,7 @@ description?: string | undefined;
|
|
|
456
473
|
access?: string | undefined;
|
|
457
474
|
defaultBranch?: string | undefined;
|
|
458
475
|
protectDefaultBranch?: boolean | undefined;
|
|
476
|
+
protectEnforceAdmins?: boolean | undefined;
|
|
459
477
|
deleteBranchOnMerge?: boolean | undefined;
|
|
460
478
|
gitCommitMessage?: string | undefined;
|
|
461
479
|
gitAuthorName?: string | undefined;
|
|
@@ -532,9 +550,11 @@ description: string;
|
|
|
532
550
|
branchName: string;
|
|
533
551
|
targetPath: string;
|
|
534
552
|
token?: string | undefined;
|
|
553
|
+
commitAction?: "create" | "update" | "delete" | undefined;
|
|
535
554
|
/** @deprecated Use projectPath instead */
|
|
536
555
|
projectid?: string | undefined;
|
|
537
556
|
removeSourceBranch?: boolean | undefined;
|
|
557
|
+
assignee?: string | undefined;
|
|
538
558
|
}>;
|
|
539
559
|
|
|
540
560
|
/**
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -303,6 +303,7 @@ repoUrl: string;
|
|
|
303
303
|
description?: string | undefined;
|
|
304
304
|
defaultBranch?: string | undefined;
|
|
305
305
|
protectDefaultBranch?: boolean | undefined;
|
|
306
|
+
protectEnforceAdmins?: boolean | undefined;
|
|
306
307
|
gitCommitMessage?: string | undefined;
|
|
307
308
|
gitAuthorName?: string | undefined;
|
|
308
309
|
gitAuthorEmail?: string | undefined;
|
|
@@ -440,6 +441,22 @@ gitAuthorEmail?: string | undefined;
|
|
|
440
441
|
sourcePath?: string | undefined;
|
|
441
442
|
}>;
|
|
442
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Creates a new action that creates a Gerrit review
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
export declare function createPublishGerritReviewAction(options: {
|
|
449
|
+
integrations: ScmIntegrationRegistry;
|
|
450
|
+
config: Config;
|
|
451
|
+
}): TemplateAction< {
|
|
452
|
+
repoUrl: string;
|
|
453
|
+
branch?: string | undefined;
|
|
454
|
+
sourcePath?: string | undefined;
|
|
455
|
+
gitCommitMessage?: string | undefined;
|
|
456
|
+
gitAuthorName?: string | undefined;
|
|
457
|
+
gitAuthorEmail?: string | undefined;
|
|
458
|
+
}>;
|
|
459
|
+
|
|
443
460
|
/**
|
|
444
461
|
* Creates a new action that initializes a git repository of the content in the workspace
|
|
445
462
|
* and publishes it to GitHub.
|
|
@@ -456,6 +473,7 @@ description?: string | undefined;
|
|
|
456
473
|
access?: string | undefined;
|
|
457
474
|
defaultBranch?: string | undefined;
|
|
458
475
|
protectDefaultBranch?: boolean | undefined;
|
|
476
|
+
protectEnforceAdmins?: boolean | undefined;
|
|
459
477
|
deleteBranchOnMerge?: boolean | undefined;
|
|
460
478
|
gitCommitMessage?: string | undefined;
|
|
461
479
|
gitAuthorName?: string | undefined;
|
|
@@ -532,9 +550,11 @@ description: string;
|
|
|
532
550
|
branchName: string;
|
|
533
551
|
targetPath: string;
|
|
534
552
|
token?: string | undefined;
|
|
553
|
+
commitAction?: "create" | "update" | "delete" | undefined;
|
|
535
554
|
/** @deprecated Use projectPath instead */
|
|
536
555
|
projectid?: string | undefined;
|
|
537
556
|
removeSourceBranch?: boolean | undefined;
|
|
557
|
+
assignee?: string | undefined;
|
|
538
558
|
}>;
|
|
539
559
|
|
|
540
560
|
/**
|
package/dist/index.cjs.js
CHANGED
|
@@ -834,6 +834,40 @@ async function initRepoAndPush({
|
|
|
834
834
|
remote: "origin"
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
+
async function commitAndPushRepo({
|
|
838
|
+
dir,
|
|
839
|
+
auth,
|
|
840
|
+
logger,
|
|
841
|
+
commitMessage,
|
|
842
|
+
gitAuthorInfo,
|
|
843
|
+
branch = "master",
|
|
844
|
+
remoteRef
|
|
845
|
+
}) {
|
|
846
|
+
var _a, _b;
|
|
847
|
+
const git = backendCommon.Git.fromAuth({
|
|
848
|
+
username: auth.username,
|
|
849
|
+
password: auth.password,
|
|
850
|
+
logger
|
|
851
|
+
});
|
|
852
|
+
await git.fetch({ dir });
|
|
853
|
+
await git.checkout({ dir, ref: branch });
|
|
854
|
+
await git.add({ dir, filepath: "." });
|
|
855
|
+
const authorInfo = {
|
|
856
|
+
name: (_a = gitAuthorInfo == null ? void 0 : gitAuthorInfo.name) != null ? _a : "Scaffolder",
|
|
857
|
+
email: (_b = gitAuthorInfo == null ? void 0 : gitAuthorInfo.email) != null ? _b : "scaffolder@backstage.io"
|
|
858
|
+
};
|
|
859
|
+
await git.commit({
|
|
860
|
+
dir,
|
|
861
|
+
message: commitMessage,
|
|
862
|
+
author: authorInfo,
|
|
863
|
+
committer: authorInfo
|
|
864
|
+
});
|
|
865
|
+
await git.push({
|
|
866
|
+
dir,
|
|
867
|
+
remote: "origin",
|
|
868
|
+
remoteRef: remoteRef != null ? remoteRef : `refs/heads/${branch}`
|
|
869
|
+
});
|
|
870
|
+
}
|
|
837
871
|
const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
838
872
|
repoName,
|
|
839
873
|
client,
|
|
@@ -841,7 +875,8 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
|
841
875
|
logger,
|
|
842
876
|
requireCodeOwnerReviews,
|
|
843
877
|
requiredStatusCheckContexts = [],
|
|
844
|
-
defaultBranch = "master"
|
|
878
|
+
defaultBranch = "master",
|
|
879
|
+
enforceAdmins = true
|
|
845
880
|
}) => {
|
|
846
881
|
const tryOnce = async () => {
|
|
847
882
|
try {
|
|
@@ -857,7 +892,7 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
|
857
892
|
contexts: requiredStatusCheckContexts
|
|
858
893
|
},
|
|
859
894
|
restrictions: null,
|
|
860
|
-
enforce_admins:
|
|
895
|
+
enforce_admins: enforceAdmins,
|
|
861
896
|
required_pull_request_reviews: {
|
|
862
897
|
required_approving_review_count: 1,
|
|
863
898
|
require_code_owner_reviews: requireCodeOwnerReviews
|
|
@@ -1009,7 +1044,7 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
|
|
|
1009
1044
|
}
|
|
1010
1045
|
return newRepo;
|
|
1011
1046
|
}
|
|
1012
|
-
async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail) {
|
|
1047
|
+
async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail) {
|
|
1013
1048
|
const gitAuthorInfo = {
|
|
1014
1049
|
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
1015
1050
|
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
@@ -1036,7 +1071,8 @@ async function initRepoPushAndProtect(remoteUrl, password, workspacePath, source
|
|
|
1036
1071
|
logger,
|
|
1037
1072
|
defaultBranch,
|
|
1038
1073
|
requireCodeOwnerReviews,
|
|
1039
|
-
requiredStatusCheckContexts
|
|
1074
|
+
requiredStatusCheckContexts,
|
|
1075
|
+
enforceAdmins: protectEnforceAdmins
|
|
1040
1076
|
});
|
|
1041
1077
|
} catch (e) {
|
|
1042
1078
|
errors.assertError(e);
|
|
@@ -1295,6 +1331,11 @@ const protectDefaultBranch = {
|
|
|
1295
1331
|
type: "boolean",
|
|
1296
1332
|
description: `Protect the default branch after creating the repository. The default value is 'true'`
|
|
1297
1333
|
};
|
|
1334
|
+
const protectEnforceAdmins = {
|
|
1335
|
+
title: "Enforce Admins On Protected Branches",
|
|
1336
|
+
type: "boolean",
|
|
1337
|
+
description: `Enforce admins to adhere to default branch protection. The default value is 'true'`
|
|
1338
|
+
};
|
|
1298
1339
|
const gitCommitMessage = {
|
|
1299
1340
|
title: "Git Commit Message",
|
|
1300
1341
|
type: "string",
|
|
@@ -1394,6 +1435,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1394
1435
|
requiredStatusCheckContexts: requiredStatusCheckContexts,
|
|
1395
1436
|
defaultBranch: defaultBranch,
|
|
1396
1437
|
protectDefaultBranch: protectDefaultBranch,
|
|
1438
|
+
protectEnforceAdmins: protectEnforceAdmins,
|
|
1397
1439
|
gitCommitMessage: gitCommitMessage,
|
|
1398
1440
|
gitAuthorName: gitAuthorName,
|
|
1399
1441
|
gitAuthorEmail: gitAuthorEmail,
|
|
@@ -1414,6 +1456,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1414
1456
|
repoUrl,
|
|
1415
1457
|
defaultBranch = "master",
|
|
1416
1458
|
protectDefaultBranch = true,
|
|
1459
|
+
protectEnforceAdmins = true,
|
|
1417
1460
|
gitCommitMessage = "initial commit",
|
|
1418
1461
|
gitAuthorName,
|
|
1419
1462
|
gitAuthorEmail,
|
|
@@ -1435,7 +1478,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1435
1478
|
const targetRepo = await client.rest.repos.get({ owner, repo });
|
|
1436
1479
|
const remoteUrl = targetRepo.data.clone_url;
|
|
1437
1480
|
const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;
|
|
1438
|
-
await initRepoPushAndProtect(remoteUrl, octokitOptions.auth, ctx.workspacePath, ctx.input.sourcePath, defaultBranch, protectDefaultBranch, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, ctx.logger, gitCommitMessage, gitAuthorName, gitAuthorEmail);
|
|
1481
|
+
await initRepoPushAndProtect(remoteUrl, octokitOptions.auth, ctx.workspacePath, ctx.input.sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, ctx.logger, gitCommitMessage, gitAuthorName, gitAuthorEmail);
|
|
1439
1482
|
ctx.output("remoteUrl", remoteUrl);
|
|
1440
1483
|
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
1441
1484
|
}
|
|
@@ -2438,6 +2481,113 @@ function createPublishGerritAction(options) {
|
|
|
2438
2481
|
});
|
|
2439
2482
|
}
|
|
2440
2483
|
|
|
2484
|
+
const generateGerritChangeId = () => {
|
|
2485
|
+
const changeId = crypto__default["default"].randomBytes(20).toString("hex");
|
|
2486
|
+
return `I${changeId}`;
|
|
2487
|
+
};
|
|
2488
|
+
function createPublishGerritReviewAction(options) {
|
|
2489
|
+
const { integrations, config } = options;
|
|
2490
|
+
return createTemplateAction({
|
|
2491
|
+
id: "publish:gerrit:review",
|
|
2492
|
+
description: "Creates a new Gerrit review.",
|
|
2493
|
+
schema: {
|
|
2494
|
+
input: {
|
|
2495
|
+
type: "object",
|
|
2496
|
+
required: ["repoUrl", "gitCommitMessage"],
|
|
2497
|
+
properties: {
|
|
2498
|
+
repoUrl: {
|
|
2499
|
+
title: "Repository Location",
|
|
2500
|
+
type: "string"
|
|
2501
|
+
},
|
|
2502
|
+
branch: {
|
|
2503
|
+
title: "Repository branch",
|
|
2504
|
+
type: "string",
|
|
2505
|
+
description: "Branch of the repository the review will be created on"
|
|
2506
|
+
},
|
|
2507
|
+
sourcePath: {
|
|
2508
|
+
type: "string",
|
|
2509
|
+
title: "Working Subdirectory",
|
|
2510
|
+
description: "Subdirectory of working directory containing the repository"
|
|
2511
|
+
},
|
|
2512
|
+
gitCommitMessage: {
|
|
2513
|
+
title: "Git Commit Message",
|
|
2514
|
+
type: "string",
|
|
2515
|
+
description: `Sets the commit message on the repository.`
|
|
2516
|
+
},
|
|
2517
|
+
gitAuthorName: {
|
|
2518
|
+
title: "Default Author Name",
|
|
2519
|
+
type: "string",
|
|
2520
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
2521
|
+
},
|
|
2522
|
+
gitAuthorEmail: {
|
|
2523
|
+
title: "Default Author Email",
|
|
2524
|
+
type: "string",
|
|
2525
|
+
description: `Sets the default author email for the commit.`
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
},
|
|
2529
|
+
output: {
|
|
2530
|
+
type: "object",
|
|
2531
|
+
properties: {
|
|
2532
|
+
reviewUrl: {
|
|
2533
|
+
title: "A URL to the review",
|
|
2534
|
+
type: "string"
|
|
2535
|
+
},
|
|
2536
|
+
repoContentsUrl: {
|
|
2537
|
+
title: "A URL to the root of the repository",
|
|
2538
|
+
type: "string"
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
},
|
|
2543
|
+
async handler(ctx) {
|
|
2544
|
+
var _a;
|
|
2545
|
+
const {
|
|
2546
|
+
repoUrl,
|
|
2547
|
+
branch = "master",
|
|
2548
|
+
sourcePath,
|
|
2549
|
+
gitAuthorName,
|
|
2550
|
+
gitAuthorEmail,
|
|
2551
|
+
gitCommitMessage
|
|
2552
|
+
} = ctx.input;
|
|
2553
|
+
const { host, repo } = parseRepoUrl(repoUrl, integrations);
|
|
2554
|
+
if (!gitCommitMessage) {
|
|
2555
|
+
throw new errors.InputError(`Missing gitCommitMessage input`);
|
|
2556
|
+
}
|
|
2557
|
+
const integrationConfig = integrations.gerrit.byHost(host);
|
|
2558
|
+
if (!integrationConfig) {
|
|
2559
|
+
throw new errors.InputError(`No matching integration configuration for host ${host}, please check your integrations config`);
|
|
2560
|
+
}
|
|
2561
|
+
const auth = {
|
|
2562
|
+
username: integrationConfig.config.username,
|
|
2563
|
+
password: integrationConfig.config.password
|
|
2564
|
+
};
|
|
2565
|
+
const gitAuthorInfo = {
|
|
2566
|
+
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
2567
|
+
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
2568
|
+
};
|
|
2569
|
+
const changeId = generateGerritChangeId();
|
|
2570
|
+
const commitMessage = `${gitCommitMessage}
|
|
2571
|
+
|
|
2572
|
+
Change-Id: ${changeId}`;
|
|
2573
|
+
await commitAndPushRepo({
|
|
2574
|
+
dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),
|
|
2575
|
+
auth,
|
|
2576
|
+
logger: ctx.logger,
|
|
2577
|
+
commitMessage,
|
|
2578
|
+
gitAuthorInfo,
|
|
2579
|
+
branch,
|
|
2580
|
+
remoteRef: `refs/for/${branch}`
|
|
2581
|
+
});
|
|
2582
|
+
const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${branch}`;
|
|
2583
|
+
const reviewUrl = `${integrationConfig.config.baseUrl}/#/q/${changeId}`;
|
|
2584
|
+
(_a = ctx.logger) == null ? void 0 : _a.info(`Review available on ${reviewUrl}`);
|
|
2585
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
2586
|
+
ctx.output("reviewUrl", reviewUrl);
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2441
2591
|
function createPublishGithubAction(options) {
|
|
2442
2592
|
const { integrations, config, githubCredentialsProvider } = options;
|
|
2443
2593
|
return createTemplateAction({
|
|
@@ -2456,6 +2606,7 @@ function createPublishGithubAction(options) {
|
|
|
2456
2606
|
repoVisibility: repoVisibility,
|
|
2457
2607
|
defaultBranch: defaultBranch,
|
|
2458
2608
|
protectDefaultBranch: protectDefaultBranch,
|
|
2609
|
+
protectEnforceAdmins: protectEnforceAdmins,
|
|
2459
2610
|
deleteBranchOnMerge: deleteBranchOnMerge,
|
|
2460
2611
|
gitCommitMessage: gitCommitMessage,
|
|
2461
2612
|
gitAuthorName: gitAuthorName,
|
|
@@ -2487,6 +2638,7 @@ function createPublishGithubAction(options) {
|
|
|
2487
2638
|
repoVisibility = "private",
|
|
2488
2639
|
defaultBranch = "master",
|
|
2489
2640
|
protectDefaultBranch = true,
|
|
2641
|
+
protectEnforceAdmins = true,
|
|
2490
2642
|
deleteBranchOnMerge = false,
|
|
2491
2643
|
gitCommitMessage = "initial commit",
|
|
2492
2644
|
gitAuthorName,
|
|
@@ -2512,7 +2664,7 @@ function createPublishGithubAction(options) {
|
|
|
2512
2664
|
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, allowRebaseMerge, access, collaborators, topics, ctx.logger);
|
|
2513
2665
|
const remoteUrl = newRepo.clone_url;
|
|
2514
2666
|
const repoContentsUrl = `${newRepo.html_url}/blob/${defaultBranch}`;
|
|
2515
|
-
await initRepoPushAndProtect(remoteUrl, octokitOptions.auth, ctx.workspacePath, ctx.input.sourcePath, defaultBranch, protectDefaultBranch, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, ctx.logger, gitCommitMessage, gitAuthorName, gitAuthorEmail);
|
|
2667
|
+
await initRepoPushAndProtect(remoteUrl, octokitOptions.auth, ctx.workspacePath, ctx.input.sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, requiredStatusCheckContexts, config, ctx.logger, gitCommitMessage, gitAuthorName, gitAuthorEmail);
|
|
2516
2668
|
ctx.output("remoteUrl", remoteUrl);
|
|
2517
2669
|
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
2518
2670
|
}
|
|
@@ -2889,10 +3041,21 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
2889
3041
|
type: "string",
|
|
2890
3042
|
description: "The token to use for authorization to GitLab"
|
|
2891
3043
|
},
|
|
3044
|
+
commitAction: {
|
|
3045
|
+
title: "Commit action",
|
|
3046
|
+
type: "string",
|
|
3047
|
+
enum: ["create", "update", "delete"],
|
|
3048
|
+
description: "The action to be used for git commit. Defaults to create."
|
|
3049
|
+
},
|
|
2892
3050
|
removeSourceBranch: {
|
|
2893
3051
|
title: "Delete source branch",
|
|
2894
3052
|
type: "boolean",
|
|
2895
3053
|
description: "Option to delete source branch once the MR has been merged. Default: false"
|
|
3054
|
+
},
|
|
3055
|
+
assignee: {
|
|
3056
|
+
title: "Merge Request Assignee",
|
|
3057
|
+
type: "string",
|
|
3058
|
+
description: "User this merge request will be assigned to"
|
|
2896
3059
|
}
|
|
2897
3060
|
}
|
|
2898
3061
|
},
|
|
@@ -2939,17 +3102,30 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
2939
3102
|
host: integrationConfig.config.baseUrl,
|
|
2940
3103
|
[tokenType]: token
|
|
2941
3104
|
});
|
|
3105
|
+
const assignee = ctx.input.assignee;
|
|
3106
|
+
let assigneeId = void 0;
|
|
3107
|
+
if (assignee !== void 0) {
|
|
3108
|
+
try {
|
|
3109
|
+
const assigneeUser = await api.Users.username(assignee);
|
|
3110
|
+
assigneeId = assigneeUser[0].id;
|
|
3111
|
+
} catch (e) {
|
|
3112
|
+
ctx.logger.warn(`Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`);
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
2942
3115
|
const targetPath = backendCommon.resolveSafeChildPath(ctx.workspacePath, ctx.input.targetPath);
|
|
2943
3116
|
const fileContents = await serializeDirectoryContents(targetPath, {
|
|
2944
3117
|
gitignore: true
|
|
2945
3118
|
});
|
|
2946
|
-
const actions = fileContents.map((file) =>
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
3119
|
+
const actions = fileContents.map((file) => {
|
|
3120
|
+
var _a2;
|
|
3121
|
+
return {
|
|
3122
|
+
action: (_a2 = ctx.input.commitAction) != null ? _a2 : "create",
|
|
3123
|
+
filePath: path__default["default"].posix.join(ctx.input.targetPath, file.path),
|
|
3124
|
+
encoding: "base64",
|
|
3125
|
+
content: file.content.toString("base64"),
|
|
3126
|
+
execute_filemode: file.executable
|
|
3127
|
+
};
|
|
3128
|
+
});
|
|
2953
3129
|
const projects = await api.Projects.show(projectPath);
|
|
2954
3130
|
const { default_branch: defaultBranch } = projects;
|
|
2955
3131
|
try {
|
|
@@ -2965,7 +3141,8 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
2965
3141
|
try {
|
|
2966
3142
|
const mergeRequestUrl = await api.MergeRequests.create(projectPath, destinationBranch, String(defaultBranch), ctx.input.title, {
|
|
2967
3143
|
description: ctx.input.description,
|
|
2968
|
-
removeSourceBranch: ctx.input.removeSourceBranch ? ctx.input.removeSourceBranch : false
|
|
3144
|
+
removeSourceBranch: ctx.input.removeSourceBranch ? ctx.input.removeSourceBranch : false,
|
|
3145
|
+
assigneeId
|
|
2969
3146
|
}).then((mergeRequest) => {
|
|
2970
3147
|
return mergeRequest.web_url;
|
|
2971
3148
|
});
|
|
@@ -3002,6 +3179,10 @@ const createBuiltinActions = (options) => {
|
|
|
3002
3179
|
integrations,
|
|
3003
3180
|
config
|
|
3004
3181
|
}),
|
|
3182
|
+
createPublishGerritReviewAction({
|
|
3183
|
+
integrations,
|
|
3184
|
+
config
|
|
3185
|
+
}),
|
|
3005
3186
|
createPublishGithubAction({
|
|
3006
3187
|
integrations,
|
|
3007
3188
|
config,
|
|
@@ -3914,6 +4095,11 @@ async function createRouter(options) {
|
|
|
3914
4095
|
});
|
|
3915
4096
|
const { token, entityRef: userEntityRef } = parseBearerToken(req.headers.authorization);
|
|
3916
4097
|
const userEntity = userEntityRef ? await catalogClient.getEntityByRef(userEntityRef, { token }) : void 0;
|
|
4098
|
+
let auditLog = `Scaffolding task for ${templateRef}`;
|
|
4099
|
+
if (userEntityRef) {
|
|
4100
|
+
auditLog += ` created by ${userEntityRef}`;
|
|
4101
|
+
}
|
|
4102
|
+
logger.info(auditLog);
|
|
3917
4103
|
const values = req.body.values;
|
|
3918
4104
|
const template = await findTemplate({
|
|
3919
4105
|
catalogApi: catalogClient,
|
|
@@ -4214,6 +4400,7 @@ exports.createPublishBitbucketCloudAction = createPublishBitbucketCloudAction;
|
|
|
4214
4400
|
exports.createPublishBitbucketServerAction = createPublishBitbucketServerAction;
|
|
4215
4401
|
exports.createPublishFileAction = createPublishFileAction;
|
|
4216
4402
|
exports.createPublishGerritAction = createPublishGerritAction;
|
|
4403
|
+
exports.createPublishGerritReviewAction = createPublishGerritReviewAction;
|
|
4217
4404
|
exports.createPublishGithubAction = createPublishGithubAction;
|
|
4218
4405
|
exports.createPublishGithubPullRequestAction = createPublishGithubPullRequestAction;
|
|
4219
4406
|
exports.createPublishGitlabAction = createPublishGitlabAction;
|