@backstage/plugin-scaffolder-backend-module-github 0.1.0-next.0 → 0.1.1-next.0
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 +29 -0
- package/dist/index.cjs.js +110 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.1.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bf92ae3: Updated dependency `octokit` to `^3.0.0`.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-common@0.20.1-next.0
|
|
10
|
+
- @backstage/config@1.1.1
|
|
11
|
+
- @backstage/errors@1.2.3
|
|
12
|
+
- @backstage/integration@1.8.0
|
|
13
|
+
- @backstage/plugin-scaffolder-node@0.2.10-next.0
|
|
14
|
+
|
|
15
|
+
## 0.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 219d7f0: Create new scaffolder module for external integrations
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- cb6a65e: The `scaffolder.defaultCommitMessage` config value is now being used if provided and uses "initial commit" when it is not provided.
|
|
24
|
+
- 28949ea: Add a new action for creating github-autolink references for a repository: `github:autolinks:create`
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/backend-common@0.20.0
|
|
27
|
+
- @backstage/plugin-scaffolder-node@0.2.9
|
|
28
|
+
- @backstage/integration@1.8.0
|
|
29
|
+
- @backstage/config@1.1.1
|
|
30
|
+
- @backstage/errors@1.2.3
|
|
31
|
+
|
|
3
32
|
## 0.1.0-next.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -297,7 +297,7 @@ async function initRepoPushAndProtect(remoteUrl, password, workspacePath, source
|
|
|
297
297
|
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
298
298
|
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
299
299
|
};
|
|
300
|
-
const commitMessage = gitCommitMessage
|
|
300
|
+
const commitMessage = getGitCommitMessage(gitCommitMessage, config) || "initial commit";
|
|
301
301
|
const commitResult = await pluginScaffolderNode.initRepoAndPush({
|
|
302
302
|
dir: pluginScaffolderNode.getRepoSourceDirectory(workspacePath, sourcePath),
|
|
303
303
|
remoteUrl,
|
|
@@ -360,8 +360,11 @@ async function validateAccessTeam(client, access) {
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
+
function getGitCommitMessage(gitCommitMessage, config) {
|
|
364
|
+
return gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage");
|
|
365
|
+
}
|
|
363
366
|
|
|
364
|
-
const examples$
|
|
367
|
+
const examples$9 = [
|
|
365
368
|
{
|
|
366
369
|
description: "GitHub Action Workflow Without Inputs.",
|
|
367
370
|
example: yaml__default["default"].stringify({
|
|
@@ -422,7 +425,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
422
425
|
return pluginScaffolderNode.createTemplateAction({
|
|
423
426
|
id: "github:actions:dispatch",
|
|
424
427
|
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
425
|
-
examples: examples$
|
|
428
|
+
examples: examples$9,
|
|
426
429
|
schema: {
|
|
427
430
|
input: {
|
|
428
431
|
type: "object",
|
|
@@ -491,7 +494,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
491
494
|
});
|
|
492
495
|
}
|
|
493
496
|
|
|
494
|
-
const examples$
|
|
497
|
+
const examples$8 = [
|
|
495
498
|
{
|
|
496
499
|
description: "Add labels to pull request or issue",
|
|
497
500
|
example: yaml__default["default"].stringify({
|
|
@@ -532,7 +535,7 @@ function createGithubIssuesLabelAction(options) {
|
|
|
532
535
|
return pluginScaffolderNode.createTemplateAction({
|
|
533
536
|
id: "github:issues:label",
|
|
534
537
|
description: "Adds labels to a pull request or issue on GitHub.",
|
|
535
|
-
examples: examples$
|
|
538
|
+
examples: examples$8,
|
|
536
539
|
schema: {
|
|
537
540
|
input: {
|
|
538
541
|
type: "object",
|
|
@@ -855,7 +858,7 @@ const commitHash = {
|
|
|
855
858
|
type: "string"
|
|
856
859
|
};
|
|
857
860
|
|
|
858
|
-
const examples$
|
|
861
|
+
const examples$7 = [
|
|
859
862
|
{
|
|
860
863
|
description: "Creates a GitHub repository with default configuration.",
|
|
861
864
|
example: yaml__default["default"].stringify({
|
|
@@ -908,7 +911,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
908
911
|
return pluginScaffolderNode.createTemplateAction({
|
|
909
912
|
id: "github:repo:create",
|
|
910
913
|
description: "Creates a GitHub repository.",
|
|
911
|
-
examples: examples$
|
|
914
|
+
examples: examples$7,
|
|
912
915
|
schema: {
|
|
913
916
|
input: {
|
|
914
917
|
type: "object",
|
|
@@ -1015,7 +1018,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
1015
1018
|
});
|
|
1016
1019
|
}
|
|
1017
1020
|
|
|
1018
|
-
const examples$
|
|
1021
|
+
const examples$6 = [
|
|
1019
1022
|
{
|
|
1020
1023
|
description: "Setup repo with no modifications to branch protection rules",
|
|
1021
1024
|
example: yaml__default["default"].stringify({
|
|
@@ -1067,7 +1070,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1067
1070
|
return pluginScaffolderNode.createTemplateAction({
|
|
1068
1071
|
id: "github:repo:push",
|
|
1069
1072
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
1070
|
-
examples: examples$
|
|
1073
|
+
examples: examples$6,
|
|
1071
1074
|
schema: {
|
|
1072
1075
|
input: {
|
|
1073
1076
|
type: "object",
|
|
@@ -1169,7 +1172,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1169
1172
|
});
|
|
1170
1173
|
}
|
|
1171
1174
|
|
|
1172
|
-
const examples$
|
|
1175
|
+
const examples$5 = [
|
|
1173
1176
|
{
|
|
1174
1177
|
description: "Create a GitHub webhook for a repository",
|
|
1175
1178
|
example: yaml__default["default"].stringify({
|
|
@@ -1278,7 +1281,7 @@ function createGithubWebhookAction(options) {
|
|
|
1278
1281
|
return pluginScaffolderNode.createTemplateAction({
|
|
1279
1282
|
id: "github:webhook",
|
|
1280
1283
|
description: "Creates webhook for a repository on GitHub.",
|
|
1281
|
-
examples: examples$
|
|
1284
|
+
examples: examples$5,
|
|
1282
1285
|
schema: {
|
|
1283
1286
|
input: {
|
|
1284
1287
|
type: "object",
|
|
@@ -1391,7 +1394,7 @@ function createGithubWebhookAction(options) {
|
|
|
1391
1394
|
});
|
|
1392
1395
|
}
|
|
1393
1396
|
|
|
1394
|
-
const examples$
|
|
1397
|
+
const examples$4 = [
|
|
1395
1398
|
{
|
|
1396
1399
|
description: "Example 1: Create and store a Deploy Key",
|
|
1397
1400
|
example: yaml__default["default"].stringify({
|
|
@@ -1416,7 +1419,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1416
1419
|
return pluginScaffolderNode.createTemplateAction({
|
|
1417
1420
|
id: "github:deployKey:create",
|
|
1418
1421
|
description: "Creates and stores Deploy Keys",
|
|
1419
|
-
examples: examples$
|
|
1422
|
+
examples: examples$4,
|
|
1420
1423
|
schema: {
|
|
1421
1424
|
input: {
|
|
1422
1425
|
type: "object",
|
|
@@ -1519,7 +1522,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1519
1522
|
});
|
|
1520
1523
|
}
|
|
1521
1524
|
|
|
1522
|
-
const examples$
|
|
1525
|
+
const examples$3 = [
|
|
1523
1526
|
{
|
|
1524
1527
|
description: "Create a GitHub Environment (No Policies, No Variables, No Secrets)",
|
|
1525
1528
|
example: yaml__default["default"].stringify({
|
|
@@ -1604,7 +1607,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1604
1607
|
return pluginScaffolderNode.createTemplateAction({
|
|
1605
1608
|
id: "github:environment:create",
|
|
1606
1609
|
description: "Creates Deployment Environments",
|
|
1607
|
-
examples: examples$
|
|
1610
|
+
examples: examples$3,
|
|
1608
1611
|
schema: {
|
|
1609
1612
|
input: {
|
|
1610
1613
|
type: "object",
|
|
@@ -1747,7 +1750,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1747
1750
|
});
|
|
1748
1751
|
}
|
|
1749
1752
|
|
|
1750
|
-
const examples$
|
|
1753
|
+
const examples$2 = [
|
|
1751
1754
|
{
|
|
1752
1755
|
description: "Create a pull request",
|
|
1753
1756
|
example: yaml__default["default"].stringify({
|
|
@@ -1969,7 +1972,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
1969
1972
|
} = options;
|
|
1970
1973
|
return pluginScaffolderNode.createTemplateAction({
|
|
1971
1974
|
id: "publish:github:pull-request",
|
|
1972
|
-
examples: examples$
|
|
1975
|
+
examples: examples$2,
|
|
1973
1976
|
schema: {
|
|
1974
1977
|
input: {
|
|
1975
1978
|
required: ["repoUrl", "title", "description", "branchName"],
|
|
@@ -2197,7 +2200,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2197
2200
|
}
|
|
2198
2201
|
};
|
|
2199
2202
|
|
|
2200
|
-
const examples = [
|
|
2203
|
+
const examples$1 = [
|
|
2201
2204
|
{
|
|
2202
2205
|
description: "Initializes a git repository of contents in workspace and publish it to GitHub with default configuration.",
|
|
2203
2206
|
example: yaml__default["default"].stringify({
|
|
@@ -2253,7 +2256,7 @@ function createPublishGithubAction(options) {
|
|
|
2253
2256
|
return pluginScaffolderNode.createTemplateAction({
|
|
2254
2257
|
id: "publish:github",
|
|
2255
2258
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
2256
|
-
examples,
|
|
2259
|
+
examples: examples$1,
|
|
2257
2260
|
schema: {
|
|
2258
2261
|
input: {
|
|
2259
2262
|
type: "object",
|
|
@@ -2325,7 +2328,7 @@ function createPublishGithubAction(options) {
|
|
|
2325
2328
|
protectDefaultBranch = true,
|
|
2326
2329
|
protectEnforceAdmins = true,
|
|
2327
2330
|
deleteBranchOnMerge = false,
|
|
2328
|
-
gitCommitMessage
|
|
2331
|
+
gitCommitMessage,
|
|
2329
2332
|
gitAuthorName,
|
|
2330
2333
|
gitAuthorEmail,
|
|
2331
2334
|
allowMergeCommit = true,
|
|
@@ -2414,7 +2417,94 @@ function createPublishGithubAction(options) {
|
|
|
2414
2417
|
});
|
|
2415
2418
|
}
|
|
2416
2419
|
|
|
2420
|
+
const examples = [
|
|
2421
|
+
{
|
|
2422
|
+
description: "GitHub alphanumric autolink reference",
|
|
2423
|
+
example: yaml__default["default"].stringify({
|
|
2424
|
+
steps: [
|
|
2425
|
+
{
|
|
2426
|
+
action: "github:autolinks:create",
|
|
2427
|
+
name: "Create an autolink reference",
|
|
2428
|
+
input: {
|
|
2429
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
2430
|
+
keyPrefix: "TICKET-",
|
|
2431
|
+
urlTemplate: "https://example.com/TICKET?query=<num>",
|
|
2432
|
+
isAlphanumeric: false
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
]
|
|
2436
|
+
})
|
|
2437
|
+
}
|
|
2438
|
+
];
|
|
2439
|
+
|
|
2440
|
+
function createGithubAutolinksAction(options) {
|
|
2441
|
+
const { integrations, githubCredentialsProvider } = options;
|
|
2442
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
2443
|
+
id: "github:autolinks:create",
|
|
2444
|
+
description: "Create an autolink reference for a repository",
|
|
2445
|
+
examples,
|
|
2446
|
+
schema: {
|
|
2447
|
+
input: {
|
|
2448
|
+
type: "object",
|
|
2449
|
+
required: ["repoUrl", "keyPrefix", "urlTemplate"],
|
|
2450
|
+
properties: {
|
|
2451
|
+
repoUrl: {
|
|
2452
|
+
title: "Repository Location",
|
|
2453
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
|
|
2454
|
+
type: "string"
|
|
2455
|
+
},
|
|
2456
|
+
keyPrefix: {
|
|
2457
|
+
title: "Key Prefix",
|
|
2458
|
+
description: "This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.",
|
|
2459
|
+
type: "string"
|
|
2460
|
+
},
|
|
2461
|
+
urlTemplate: {
|
|
2462
|
+
title: "URL Template",
|
|
2463
|
+
description: "The URL must contain <num> for the reference number. <num> matches different characters depending on the value of isAlphanumeric.",
|
|
2464
|
+
type: "string"
|
|
2465
|
+
},
|
|
2466
|
+
isAlphanumeric: {
|
|
2467
|
+
title: "Alphanumeric",
|
|
2468
|
+
description: "Whether this autolink reference matches alphanumeric characters. If true, the <num> parameter of the url_template matches alphanumeric characters A-Z (case insensitive), 0-9, and -. If false, this autolink reference only matches numeric characters. Default: true",
|
|
2469
|
+
type: "boolean"
|
|
2470
|
+
},
|
|
2471
|
+
token: {
|
|
2472
|
+
title: "Authentication Token",
|
|
2473
|
+
type: "string",
|
|
2474
|
+
description: "The token to use for authorization to GitHub"
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
},
|
|
2479
|
+
async handler(ctx) {
|
|
2480
|
+
const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } = ctx.input;
|
|
2481
|
+
ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);
|
|
2482
|
+
const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
2483
|
+
if (!owner) {
|
|
2484
|
+
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
2485
|
+
}
|
|
2486
|
+
const client = new octokit.Octokit(
|
|
2487
|
+
await getOctokitOptions({
|
|
2488
|
+
integrations,
|
|
2489
|
+
repoUrl,
|
|
2490
|
+
credentialsProvider: githubCredentialsProvider,
|
|
2491
|
+
token
|
|
2492
|
+
})
|
|
2493
|
+
);
|
|
2494
|
+
await client.rest.repos.createAutolink({
|
|
2495
|
+
owner,
|
|
2496
|
+
repo,
|
|
2497
|
+
key_prefix: keyPrefix,
|
|
2498
|
+
url_template: urlTemplate,
|
|
2499
|
+
is_alphanumeric: isAlphanumeric
|
|
2500
|
+
});
|
|
2501
|
+
ctx.logger.info(`Autolink reference created successfully`);
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2417
2506
|
exports.createGithubActionsDispatchAction = createGithubActionsDispatchAction;
|
|
2507
|
+
exports.createGithubAutolinksAction = createGithubAutolinksAction;
|
|
2418
2508
|
exports.createGithubDeployKeyAction = createGithubDeployKeyAction;
|
|
2419
2509
|
exports.createGithubEnvironmentAction = createGithubEnvironmentAction;
|
|
2420
2510
|
exports.createGithubIssuesLabelAction = createGithubIssuesLabelAction;
|