@backstage/plugin-scaffolder-backend-module-github 0.3.2 → 0.4.0-next.1
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 +20 -11
- package/dist/index.cjs.js +169 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.4.0-next.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 141f366: Added action to enable GitHub Pages on a repo
|
|
8
|
+
- dfaa28d: Adds `requireLastPushApproval` input property to configure Branch Protection Settings in `github:publish` action
|
|
9
|
+
|
|
10
|
+
Adds `requireLastPushApproval` input property to configure Branch Protection Settings in `github:repo:push` action
|
|
11
|
+
|
|
8
12
|
- Updated dependencies
|
|
9
|
-
- @backstage/backend-
|
|
10
|
-
- @backstage/plugin-
|
|
11
|
-
- @backstage/backend-common@0.23.2
|
|
13
|
+
- @backstage/backend-common@0.23.3-next.1
|
|
14
|
+
- @backstage/backend-plugin-api@0.6.22-next.1
|
|
12
15
|
- @backstage/config@1.2.0
|
|
13
16
|
- @backstage/errors@1.2.4
|
|
14
|
-
- @backstage/integration@1.
|
|
17
|
+
- @backstage/integration@1.13.0-next.0
|
|
18
|
+
- @backstage/plugin-scaffolder-node@0.4.8-next.1
|
|
15
19
|
|
|
16
|
-
## 0.
|
|
20
|
+
## 0.4.0-next.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 70c4b36: Adds support for custom tag policies when creating GitHub environments.
|
|
17
25
|
|
|
18
26
|
### Patch Changes
|
|
19
27
|
|
|
28
|
+
- 4410fed: Fixed issue with octokit call missing owner and repo when creating environment variables and secrets using github:environment:create action
|
|
20
29
|
- Updated dependencies
|
|
21
|
-
- @backstage/backend-
|
|
22
|
-
- @backstage/
|
|
23
|
-
- @backstage/
|
|
30
|
+
- @backstage/backend-plugin-api@0.6.21-next.0
|
|
31
|
+
- @backstage/backend-common@0.23.2-next.0
|
|
32
|
+
- @backstage/integration@1.13.0-next.0
|
|
33
|
+
- @backstage/plugin-scaffolder-node@0.4.7-next.0
|
|
24
34
|
- @backstage/config@1.2.0
|
|
25
35
|
- @backstage/errors@1.2.4
|
|
26
|
-
- @backstage/integration@1.12.0
|
|
27
36
|
|
|
28
37
|
## 0.3.0
|
|
29
38
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -12,6 +12,7 @@ var webhooks = require('@octokit/webhooks');
|
|
|
12
12
|
var path = require('path');
|
|
13
13
|
var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request');
|
|
14
14
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
15
|
+
var pluginScaffolderBackendModuleGithub = require('@backstage/plugin-scaffolder-backend-module-github');
|
|
15
16
|
var alpha = require('@backstage/plugin-scaffolder-node/alpha');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -32,6 +33,7 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
|
32
33
|
requiredStatusCheckContexts = [],
|
|
33
34
|
requireBranchesToBeUpToDate = true,
|
|
34
35
|
requiredConversationResolution = false,
|
|
36
|
+
requireLastPushApproval = false,
|
|
35
37
|
defaultBranch = "master",
|
|
36
38
|
enforceAdmins = true,
|
|
37
39
|
dismissStaleReviews = false,
|
|
@@ -63,7 +65,8 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
|
|
|
63
65
|
required_approving_review_count: requiredApprovingReviewCount,
|
|
64
66
|
require_code_owner_reviews: requireCodeOwnerReviews,
|
|
65
67
|
bypass_pull_request_allowances: bypassPullRequestAllowances,
|
|
66
|
-
dismiss_stale_reviews: dismissStaleReviews
|
|
68
|
+
dismiss_stale_reviews: dismissStaleReviews,
|
|
69
|
+
require_last_push_approval: requireLastPushApproval
|
|
67
70
|
},
|
|
68
71
|
required_conversation_resolution: requiredConversationResolution
|
|
69
72
|
});
|
|
@@ -303,7 +306,7 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
|
|
|
303
306
|
}
|
|
304
307
|
return newRepo;
|
|
305
308
|
}
|
|
306
|
-
async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, bypassPullRequestAllowances, requiredApprovingReviewCount, restrictions, requiredStatusCheckContexts, requireBranchesToBeUpToDate, requiredConversationResolution, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail, dismissStaleReviews, requiredCommitSigning) {
|
|
309
|
+
async function initRepoPushAndProtect(remoteUrl, password, workspacePath, sourcePath, defaultBranch, protectDefaultBranch, protectEnforceAdmins, owner, client, repo, requireCodeOwnerReviews, bypassPullRequestAllowances, requiredApprovingReviewCount, restrictions, requiredStatusCheckContexts, requireBranchesToBeUpToDate, requiredConversationResolution, requireLastPushApproval, config, logger, gitCommitMessage, gitAuthorName, gitAuthorEmail, dismissStaleReviews, requiredCommitSigning) {
|
|
307
310
|
const gitAuthorInfo = {
|
|
308
311
|
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
309
312
|
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
@@ -336,6 +339,7 @@ async function initRepoPushAndProtect(remoteUrl, password, workspacePath, source
|
|
|
336
339
|
requiredStatusCheckContexts,
|
|
337
340
|
requireBranchesToBeUpToDate,
|
|
338
341
|
requiredConversationResolution,
|
|
342
|
+
requireLastPushApproval,
|
|
339
343
|
enforceAdmins: protectEnforceAdmins,
|
|
340
344
|
dismissStaleReviews,
|
|
341
345
|
requiredCommitSigning
|
|
@@ -350,10 +354,8 @@ async function initRepoPushAndProtect(remoteUrl, password, workspacePath, source
|
|
|
350
354
|
return { commitHash: commitResult.commitHash };
|
|
351
355
|
}
|
|
352
356
|
function extractCollaboratorName(collaborator) {
|
|
353
|
-
if ("username" in collaborator)
|
|
354
|
-
|
|
355
|
-
if ("user" in collaborator)
|
|
356
|
-
return collaborator.user;
|
|
357
|
+
if ("username" in collaborator) return collaborator.username;
|
|
358
|
+
if ("user" in collaborator) return collaborator.user;
|
|
357
359
|
return collaborator.team;
|
|
358
360
|
}
|
|
359
361
|
async function validateAccessTeam(client, access) {
|
|
@@ -375,7 +377,7 @@ function getGitCommitMessage(gitCommitMessage, config) {
|
|
|
375
377
|
return gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage");
|
|
376
378
|
}
|
|
377
379
|
|
|
378
|
-
const examples$
|
|
380
|
+
const examples$a = [
|
|
379
381
|
{
|
|
380
382
|
description: "GitHub Action Workflow Without Inputs.",
|
|
381
383
|
example: yaml__default.default.stringify({
|
|
@@ -436,7 +438,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
436
438
|
return pluginScaffolderNode.createTemplateAction({
|
|
437
439
|
id: "github:actions:dispatch",
|
|
438
440
|
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
439
|
-
examples: examples$
|
|
441
|
+
examples: examples$a,
|
|
440
442
|
schema: {
|
|
441
443
|
input: {
|
|
442
444
|
type: "object",
|
|
@@ -505,7 +507,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
505
507
|
});
|
|
506
508
|
}
|
|
507
509
|
|
|
508
|
-
const examples$
|
|
510
|
+
const examples$9 = [
|
|
509
511
|
{
|
|
510
512
|
description: "Add labels to pull request or issue",
|
|
511
513
|
example: yaml__default.default.stringify({
|
|
@@ -546,7 +548,7 @@ function createGithubIssuesLabelAction(options) {
|
|
|
546
548
|
return pluginScaffolderNode.createTemplateAction({
|
|
547
549
|
id: "github:issues:label",
|
|
548
550
|
description: "Adds labels to a pull request or issue on GitHub.",
|
|
549
|
-
examples: examples$
|
|
551
|
+
examples: examples$9,
|
|
550
552
|
schema: {
|
|
551
553
|
input: {
|
|
552
554
|
type: "object",
|
|
@@ -656,6 +658,11 @@ const requiredConversationResolution = {
|
|
|
656
658
|
description: "Requires all conversations on code to be resolved before a pull request can be merged into this branch",
|
|
657
659
|
type: "boolean"
|
|
658
660
|
};
|
|
661
|
+
const requireLastPushApproval = {
|
|
662
|
+
title: "Require last push approval",
|
|
663
|
+
type: "boolean",
|
|
664
|
+
description: `Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is 'false'`
|
|
665
|
+
};
|
|
659
666
|
const repoVisibility = {
|
|
660
667
|
title: "Repository Visibility",
|
|
661
668
|
type: "string",
|
|
@@ -890,7 +897,7 @@ const commitHash = {
|
|
|
890
897
|
type: "string"
|
|
891
898
|
};
|
|
892
899
|
|
|
893
|
-
const examples$
|
|
900
|
+
const examples$8 = [
|
|
894
901
|
{
|
|
895
902
|
description: "Creates a GitHub repository with default configuration.",
|
|
896
903
|
example: yaml__default.default.stringify({
|
|
@@ -943,7 +950,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
943
950
|
return pluginScaffolderNode.createTemplateAction({
|
|
944
951
|
id: "github:repo:create",
|
|
945
952
|
description: "Creates a GitHub repository.",
|
|
946
|
-
examples: examples$
|
|
953
|
+
examples: examples$8,
|
|
947
954
|
schema: {
|
|
948
955
|
input: {
|
|
949
956
|
type: "object",
|
|
@@ -1053,7 +1060,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
1053
1060
|
});
|
|
1054
1061
|
}
|
|
1055
1062
|
|
|
1056
|
-
const examples$
|
|
1063
|
+
const examples$7 = [
|
|
1057
1064
|
{
|
|
1058
1065
|
description: "Setup repo with no modifications to branch protection rules",
|
|
1059
1066
|
example: yaml__default.default.stringify({
|
|
@@ -1105,7 +1112,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1105
1112
|
return pluginScaffolderNode.createTemplateAction({
|
|
1106
1113
|
id: "github:repo:push",
|
|
1107
1114
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
1108
|
-
examples: examples$
|
|
1115
|
+
examples: examples$7,
|
|
1109
1116
|
schema: {
|
|
1110
1117
|
input: {
|
|
1111
1118
|
type: "object",
|
|
@@ -1120,6 +1127,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1120
1127
|
restrictions: restrictions,
|
|
1121
1128
|
requireBranchesToBeUpToDate: requireBranchesToBeUpToDate,
|
|
1122
1129
|
requiredConversationResolution: requiredConversationResolution,
|
|
1130
|
+
requireLastPushApproval: requireLastPushApproval,
|
|
1123
1131
|
defaultBranch: defaultBranch,
|
|
1124
1132
|
protectDefaultBranch: protectDefaultBranch,
|
|
1125
1133
|
protectEnforceAdmins: protectEnforceAdmins,
|
|
@@ -1157,6 +1165,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1157
1165
|
requiredStatusCheckContexts = [],
|
|
1158
1166
|
requireBranchesToBeUpToDate = true,
|
|
1159
1167
|
requiredConversationResolution = false,
|
|
1168
|
+
requireLastPushApproval = false,
|
|
1160
1169
|
token: providedToken,
|
|
1161
1170
|
requiredCommitSigning = false
|
|
1162
1171
|
} = ctx.input;
|
|
@@ -1192,6 +1201,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1192
1201
|
requiredStatusCheckContexts,
|
|
1193
1202
|
requireBranchesToBeUpToDate,
|
|
1194
1203
|
requiredConversationResolution,
|
|
1204
|
+
requireLastPushApproval,
|
|
1195
1205
|
config,
|
|
1196
1206
|
ctx.logger,
|
|
1197
1207
|
gitCommitMessage,
|
|
@@ -1207,7 +1217,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1207
1217
|
});
|
|
1208
1218
|
}
|
|
1209
1219
|
|
|
1210
|
-
const examples$
|
|
1220
|
+
const examples$6 = [
|
|
1211
1221
|
{
|
|
1212
1222
|
description: "Create a GitHub webhook for a repository",
|
|
1213
1223
|
example: yaml__default.default.stringify({
|
|
@@ -1316,7 +1326,7 @@ function createGithubWebhookAction(options) {
|
|
|
1316
1326
|
return pluginScaffolderNode.createTemplateAction({
|
|
1317
1327
|
id: "github:webhook",
|
|
1318
1328
|
description: "Creates webhook for a repository on GitHub.",
|
|
1319
|
-
examples: examples$
|
|
1329
|
+
examples: examples$6,
|
|
1320
1330
|
supportsDryRun: true,
|
|
1321
1331
|
schema: {
|
|
1322
1332
|
input: {
|
|
@@ -1434,7 +1444,7 @@ function createGithubWebhookAction(options) {
|
|
|
1434
1444
|
});
|
|
1435
1445
|
}
|
|
1436
1446
|
|
|
1437
|
-
const examples$
|
|
1447
|
+
const examples$5 = [
|
|
1438
1448
|
{
|
|
1439
1449
|
description: "Example 1: Create and store a Deploy Key",
|
|
1440
1450
|
example: yaml__default.default.stringify({
|
|
@@ -1459,7 +1469,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1459
1469
|
return pluginScaffolderNode.createTemplateAction({
|
|
1460
1470
|
id: "github:deployKey:create",
|
|
1461
1471
|
description: "Creates and stores Deploy Keys",
|
|
1462
|
-
examples: examples$
|
|
1472
|
+
examples: examples$5,
|
|
1463
1473
|
schema: {
|
|
1464
1474
|
input: {
|
|
1465
1475
|
type: "object",
|
|
@@ -1562,7 +1572,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1562
1572
|
});
|
|
1563
1573
|
}
|
|
1564
1574
|
|
|
1565
|
-
const examples$
|
|
1575
|
+
const examples$4 = [
|
|
1566
1576
|
{
|
|
1567
1577
|
description: "Create a GitHub Environment (No Policies, No Variables, No Secrets)",
|
|
1568
1578
|
example: yaml__default.default.stringify({
|
|
@@ -1647,7 +1657,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1647
1657
|
return pluginScaffolderNode.createTemplateAction({
|
|
1648
1658
|
id: "github:environment:create",
|
|
1649
1659
|
description: "Creates Deployment Environments",
|
|
1650
|
-
examples: examples$
|
|
1660
|
+
examples: examples$4,
|
|
1651
1661
|
schema: {
|
|
1652
1662
|
input: {
|
|
1653
1663
|
type: "object",
|
|
@@ -1691,6 +1701,16 @@ function createGithubEnvironmentAction(options) {
|
|
|
1691
1701
|
type: "string"
|
|
1692
1702
|
}
|
|
1693
1703
|
},
|
|
1704
|
+
customTagPolicyNames: {
|
|
1705
|
+
title: "Custom Tag Policy Name",
|
|
1706
|
+
description: `The name pattern that tags must match in order to deploy to the environment.
|
|
1707
|
+
|
|
1708
|
+
Wildcard characters will not match /. For example, to match tags that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
|
|
1709
|
+
type: "array",
|
|
1710
|
+
items: {
|
|
1711
|
+
type: "string"
|
|
1712
|
+
}
|
|
1713
|
+
},
|
|
1694
1714
|
environmentVariables: {
|
|
1695
1715
|
title: "Environment Variables",
|
|
1696
1716
|
description: `Environment variables attached to the deployment environment`,
|
|
@@ -1715,6 +1735,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1715
1735
|
name,
|
|
1716
1736
|
deploymentBranchPolicy,
|
|
1717
1737
|
customBranchPolicyNames,
|
|
1738
|
+
customTagPolicyNames,
|
|
1718
1739
|
environmentVariables,
|
|
1719
1740
|
secrets,
|
|
1720
1741
|
token: providedToken
|
|
@@ -1744,6 +1765,18 @@ function createGithubEnvironmentAction(options) {
|
|
|
1744
1765
|
await client.rest.repos.createDeploymentBranchPolicy({
|
|
1745
1766
|
owner,
|
|
1746
1767
|
repo,
|
|
1768
|
+
type: "branch",
|
|
1769
|
+
environment_name: name,
|
|
1770
|
+
name: item
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
if (customTagPolicyNames) {
|
|
1775
|
+
for (const item of customTagPolicyNames) {
|
|
1776
|
+
await client.rest.repos.createDeploymentBranchPolicy({
|
|
1777
|
+
owner,
|
|
1778
|
+
repo,
|
|
1779
|
+
type: "tag",
|
|
1747
1780
|
environment_name: name,
|
|
1748
1781
|
name: item
|
|
1749
1782
|
});
|
|
@@ -1794,7 +1827,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1794
1827
|
});
|
|
1795
1828
|
}
|
|
1796
1829
|
|
|
1797
|
-
const examples$
|
|
1830
|
+
const examples$3 = [
|
|
1798
1831
|
{
|
|
1799
1832
|
description: "Create a pull request",
|
|
1800
1833
|
example: yaml__default.default.stringify({
|
|
@@ -2078,7 +2111,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2078
2111
|
} = options;
|
|
2079
2112
|
return pluginScaffolderNode.createTemplateAction({
|
|
2080
2113
|
id: "publish:github:pull-request",
|
|
2081
|
-
examples: examples$
|
|
2114
|
+
examples: examples$3,
|
|
2082
2115
|
supportsDryRun: true,
|
|
2083
2116
|
schema: {
|
|
2084
2117
|
input: {
|
|
@@ -2238,10 +2271,8 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2238
2271
|
gitignore: true
|
|
2239
2272
|
});
|
|
2240
2273
|
const determineFileMode = (file) => {
|
|
2241
|
-
if (file.symlink)
|
|
2242
|
-
|
|
2243
|
-
if (file.executable)
|
|
2244
|
-
return "100755";
|
|
2274
|
+
if (file.symlink) return "120000";
|
|
2275
|
+
if (file.executable) return "100755";
|
|
2245
2276
|
return "100644";
|
|
2246
2277
|
};
|
|
2247
2278
|
const determineFileEncoding = (file) => file.symlink ? "utf-8" : "base64";
|
|
@@ -2364,7 +2395,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2364
2395
|
}
|
|
2365
2396
|
};
|
|
2366
2397
|
|
|
2367
|
-
const examples$
|
|
2398
|
+
const examples$2 = [
|
|
2368
2399
|
{
|
|
2369
2400
|
description: "Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.",
|
|
2370
2401
|
example: yaml__default.default.stringify({
|
|
@@ -2419,7 +2450,7 @@ function createPublishGithubAction(options) {
|
|
|
2419
2450
|
return pluginScaffolderNode.createTemplateAction({
|
|
2420
2451
|
id: "publish:github",
|
|
2421
2452
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
2422
|
-
examples: examples$
|
|
2453
|
+
examples: examples$2,
|
|
2423
2454
|
schema: {
|
|
2424
2455
|
input: {
|
|
2425
2456
|
type: "object",
|
|
@@ -2437,6 +2468,7 @@ function createPublishGithubAction(options) {
|
|
|
2437
2468
|
requiredStatusCheckContexts: requiredStatusCheckContexts,
|
|
2438
2469
|
requireBranchesToBeUpToDate: requireBranchesToBeUpToDate,
|
|
2439
2470
|
requiredConversationResolution: requiredConversationResolution,
|
|
2471
|
+
requireLastPushApproval: requireLastPushApproval,
|
|
2440
2472
|
repoVisibility: repoVisibility,
|
|
2441
2473
|
defaultBranch: defaultBranch,
|
|
2442
2474
|
protectDefaultBranch: protectDefaultBranch,
|
|
@@ -2487,6 +2519,7 @@ function createPublishGithubAction(options) {
|
|
|
2487
2519
|
requiredStatusCheckContexts = [],
|
|
2488
2520
|
requireBranchesToBeUpToDate = true,
|
|
2489
2521
|
requiredConversationResolution = false,
|
|
2522
|
+
requireLastPushApproval = false,
|
|
2490
2523
|
repoVisibility = "private",
|
|
2491
2524
|
defaultBranch = "master",
|
|
2492
2525
|
protectDefaultBranch = true,
|
|
@@ -2568,6 +2601,7 @@ function createPublishGithubAction(options) {
|
|
|
2568
2601
|
requiredStatusCheckContexts,
|
|
2569
2602
|
requireBranchesToBeUpToDate,
|
|
2570
2603
|
requiredConversationResolution,
|
|
2604
|
+
requireLastPushApproval,
|
|
2571
2605
|
config,
|
|
2572
2606
|
ctx.logger,
|
|
2573
2607
|
gitCommitMessage,
|
|
@@ -2583,7 +2617,7 @@ function createPublishGithubAction(options) {
|
|
|
2583
2617
|
});
|
|
2584
2618
|
}
|
|
2585
2619
|
|
|
2586
|
-
const examples = [
|
|
2620
|
+
const examples$1 = [
|
|
2587
2621
|
{
|
|
2588
2622
|
description: "GitHub alphanumric autolink reference",
|
|
2589
2623
|
example: yaml__default.default.stringify({
|
|
@@ -2608,7 +2642,7 @@ function createGithubAutolinksAction(options) {
|
|
|
2608
2642
|
return pluginScaffolderNode.createTemplateAction({
|
|
2609
2643
|
id: "github:autolinks:create",
|
|
2610
2644
|
description: "Create an autolink reference for a repository",
|
|
2611
|
-
examples,
|
|
2645
|
+
examples: examples$1,
|
|
2612
2646
|
schema: {
|
|
2613
2647
|
input: {
|
|
2614
2648
|
type: "object",
|
|
@@ -2669,6 +2703,106 @@ function createGithubAutolinksAction(options) {
|
|
|
2669
2703
|
});
|
|
2670
2704
|
}
|
|
2671
2705
|
|
|
2706
|
+
const examples = [
|
|
2707
|
+
{
|
|
2708
|
+
description: "Enables GitHub Pages for a repository.",
|
|
2709
|
+
example: yaml__default.default.stringify({
|
|
2710
|
+
steps: [
|
|
2711
|
+
{
|
|
2712
|
+
action: "github:pages",
|
|
2713
|
+
id: "github-pages",
|
|
2714
|
+
name: "Enable GitHub Pages",
|
|
2715
|
+
input: {
|
|
2716
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
2717
|
+
buildType: "workflow",
|
|
2718
|
+
sourceBranch: "main",
|
|
2719
|
+
sourcePath: "/",
|
|
2720
|
+
token: "gph_YourGitHubToken"
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
]
|
|
2724
|
+
})
|
|
2725
|
+
}
|
|
2726
|
+
];
|
|
2727
|
+
|
|
2728
|
+
function createGithubPagesEnableAction(options) {
|
|
2729
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
2730
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
2731
|
+
id: "github:pages:enable",
|
|
2732
|
+
examples,
|
|
2733
|
+
description: "Enables GitHub Pages for a repository.",
|
|
2734
|
+
schema: {
|
|
2735
|
+
input: {
|
|
2736
|
+
type: "object",
|
|
2737
|
+
required: ["repoUrl"],
|
|
2738
|
+
properties: {
|
|
2739
|
+
repoUrl: {
|
|
2740
|
+
title: "Repository Location",
|
|
2741
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
2742
|
+
type: "string"
|
|
2743
|
+
},
|
|
2744
|
+
buildType: {
|
|
2745
|
+
title: "Build Type",
|
|
2746
|
+
type: "string",
|
|
2747
|
+
description: 'The GitHub Pages build type - "legacy" or "workflow". Default is "workflow'
|
|
2748
|
+
},
|
|
2749
|
+
sourceBranch: {
|
|
2750
|
+
title: "Source Branch",
|
|
2751
|
+
type: "string",
|
|
2752
|
+
description: 'The the GitHub Pages source branch. Default is "main"'
|
|
2753
|
+
},
|
|
2754
|
+
sourcePath: {
|
|
2755
|
+
title: "Source Path",
|
|
2756
|
+
type: "string",
|
|
2757
|
+
description: 'The the GitHub Pages source path - "/" or "/docs". Default is "/"'
|
|
2758
|
+
},
|
|
2759
|
+
token: {
|
|
2760
|
+
title: "Authorization Token",
|
|
2761
|
+
type: "string",
|
|
2762
|
+
description: "The token to use for authorization to GitHub"
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
},
|
|
2767
|
+
async handler(ctx) {
|
|
2768
|
+
const {
|
|
2769
|
+
repoUrl,
|
|
2770
|
+
buildType = "workflow",
|
|
2771
|
+
sourceBranch = "main",
|
|
2772
|
+
sourcePath = "/",
|
|
2773
|
+
token: providedToken
|
|
2774
|
+
} = ctx.input;
|
|
2775
|
+
const octokitOptions = await pluginScaffolderBackendModuleGithub.getOctokitOptions({
|
|
2776
|
+
integrations,
|
|
2777
|
+
credentialsProvider: githubCredentialsProvider,
|
|
2778
|
+
token: providedToken,
|
|
2779
|
+
repoUrl
|
|
2780
|
+
});
|
|
2781
|
+
const client = new octokit.Octokit(octokitOptions);
|
|
2782
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
2783
|
+
if (!owner) {
|
|
2784
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
2785
|
+
}
|
|
2786
|
+
ctx.logger.info(
|
|
2787
|
+
`Attempting to enable GitHub Pages for ${owner}/${repo} with "${buildType}" build type, on source branch "${sourceBranch}" and source path "${sourcePath}"`
|
|
2788
|
+
);
|
|
2789
|
+
await client.request("POST /repos/{owner}/{repo}/pages", {
|
|
2790
|
+
owner,
|
|
2791
|
+
repo,
|
|
2792
|
+
build_type: buildType,
|
|
2793
|
+
source: {
|
|
2794
|
+
branch: sourceBranch,
|
|
2795
|
+
path: sourcePath
|
|
2796
|
+
},
|
|
2797
|
+
headers: {
|
|
2798
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2801
|
+
ctx.logger.info("Completed enabling GitHub Pages");
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2672
2806
|
const githubModule = backendPluginApi.createBackendModule({
|
|
2673
2807
|
pluginId: "scaffolder",
|
|
2674
2808
|
moduleId: "github",
|
|
@@ -2718,6 +2852,10 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
2718
2852
|
integrations,
|
|
2719
2853
|
githubCredentialsProvider,
|
|
2720
2854
|
config
|
|
2855
|
+
}),
|
|
2856
|
+
createGithubPagesEnableAction({
|
|
2857
|
+
integrations,
|
|
2858
|
+
githubCredentialsProvider
|
|
2721
2859
|
})
|
|
2722
2860
|
);
|
|
2723
2861
|
}
|
|
@@ -2730,6 +2868,7 @@ exports.createGithubAutolinksAction = createGithubAutolinksAction;
|
|
|
2730
2868
|
exports.createGithubDeployKeyAction = createGithubDeployKeyAction;
|
|
2731
2869
|
exports.createGithubEnvironmentAction = createGithubEnvironmentAction;
|
|
2732
2870
|
exports.createGithubIssuesLabelAction = createGithubIssuesLabelAction;
|
|
2871
|
+
exports.createGithubPagesEnableAction = createGithubPagesEnableAction;
|
|
2733
2872
|
exports.createGithubRepoCreateAction = createGithubRepoCreateAction;
|
|
2734
2873
|
exports.createGithubRepoPushAction = createGithubRepoPushAction;
|
|
2735
2874
|
exports.createGithubWebhookAction = createGithubWebhookAction;
|