@backstage/plugin-scaffolder-backend-module-github 0.0.0-nightly-20240701022140 → 0.0.0-nightly-20240702021736
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 +6 -5
- package/dist/index.cjs.js +126 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +17 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20240702021736
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
+
- 141f366: Added action to enable GitHub Pages on a repo
|
|
11
12
|
- 4410fed: Fixed issue with octokit call missing owner and repo when creating environment variables and secrets using github:environment:create action
|
|
12
13
|
- dfaa28d: Adds `requireLastPushApproval` input property to configure Branch Protection Settings in `github:publish` action
|
|
13
14
|
|
|
14
15
|
Adds `requireLastPushApproval` input property to configure Branch Protection Settings in `github:repo:push` action
|
|
15
16
|
|
|
16
17
|
- Updated dependencies
|
|
17
|
-
- @backstage/backend-plugin-api@0.0.0-nightly-
|
|
18
|
-
- @backstage/backend-common@0.0.0-nightly-
|
|
19
|
-
- @backstage/integration@0.0.0-nightly-
|
|
20
|
-
- @backstage/plugin-scaffolder-node@0.0.0-nightly-
|
|
18
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20240702021736
|
|
19
|
+
- @backstage/backend-common@0.0.0-nightly-20240702021736
|
|
20
|
+
- @backstage/integration@0.0.0-nightly-20240702021736
|
|
21
|
+
- @backstage/plugin-scaffolder-node@0.0.0-nightly-20240702021736
|
|
21
22
|
- @backstage/config@1.2.0
|
|
22
23
|
- @backstage/errors@1.2.4
|
|
23
24
|
|
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 }; }
|
|
@@ -376,7 +377,7 @@ function getGitCommitMessage(gitCommitMessage, config) {
|
|
|
376
377
|
return gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage");
|
|
377
378
|
}
|
|
378
379
|
|
|
379
|
-
const examples$
|
|
380
|
+
const examples$a = [
|
|
380
381
|
{
|
|
381
382
|
description: "GitHub Action Workflow Without Inputs.",
|
|
382
383
|
example: yaml__default.default.stringify({
|
|
@@ -437,7 +438,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
437
438
|
return pluginScaffolderNode.createTemplateAction({
|
|
438
439
|
id: "github:actions:dispatch",
|
|
439
440
|
description: "Dispatches a GitHub Action workflow for a given branch or tag",
|
|
440
|
-
examples: examples$
|
|
441
|
+
examples: examples$a,
|
|
441
442
|
schema: {
|
|
442
443
|
input: {
|
|
443
444
|
type: "object",
|
|
@@ -506,7 +507,7 @@ function createGithubActionsDispatchAction(options) {
|
|
|
506
507
|
});
|
|
507
508
|
}
|
|
508
509
|
|
|
509
|
-
const examples$
|
|
510
|
+
const examples$9 = [
|
|
510
511
|
{
|
|
511
512
|
description: "Add labels to pull request or issue",
|
|
512
513
|
example: yaml__default.default.stringify({
|
|
@@ -547,7 +548,7 @@ function createGithubIssuesLabelAction(options) {
|
|
|
547
548
|
return pluginScaffolderNode.createTemplateAction({
|
|
548
549
|
id: "github:issues:label",
|
|
549
550
|
description: "Adds labels to a pull request or issue on GitHub.",
|
|
550
|
-
examples: examples$
|
|
551
|
+
examples: examples$9,
|
|
551
552
|
schema: {
|
|
552
553
|
input: {
|
|
553
554
|
type: "object",
|
|
@@ -896,7 +897,7 @@ const commitHash = {
|
|
|
896
897
|
type: "string"
|
|
897
898
|
};
|
|
898
899
|
|
|
899
|
-
const examples$
|
|
900
|
+
const examples$8 = [
|
|
900
901
|
{
|
|
901
902
|
description: "Creates a GitHub repository with default configuration.",
|
|
902
903
|
example: yaml__default.default.stringify({
|
|
@@ -949,7 +950,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
949
950
|
return pluginScaffolderNode.createTemplateAction({
|
|
950
951
|
id: "github:repo:create",
|
|
951
952
|
description: "Creates a GitHub repository.",
|
|
952
|
-
examples: examples$
|
|
953
|
+
examples: examples$8,
|
|
953
954
|
schema: {
|
|
954
955
|
input: {
|
|
955
956
|
type: "object",
|
|
@@ -1059,7 +1060,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
1059
1060
|
});
|
|
1060
1061
|
}
|
|
1061
1062
|
|
|
1062
|
-
const examples$
|
|
1063
|
+
const examples$7 = [
|
|
1063
1064
|
{
|
|
1064
1065
|
description: "Setup repo with no modifications to branch protection rules",
|
|
1065
1066
|
example: yaml__default.default.stringify({
|
|
@@ -1111,7 +1112,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1111
1112
|
return pluginScaffolderNode.createTemplateAction({
|
|
1112
1113
|
id: "github:repo:push",
|
|
1113
1114
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
1114
|
-
examples: examples$
|
|
1115
|
+
examples: examples$7,
|
|
1115
1116
|
schema: {
|
|
1116
1117
|
input: {
|
|
1117
1118
|
type: "object",
|
|
@@ -1216,7 +1217,7 @@ function createGithubRepoPushAction(options) {
|
|
|
1216
1217
|
});
|
|
1217
1218
|
}
|
|
1218
1219
|
|
|
1219
|
-
const examples$
|
|
1220
|
+
const examples$6 = [
|
|
1220
1221
|
{
|
|
1221
1222
|
description: "Create a GitHub webhook for a repository",
|
|
1222
1223
|
example: yaml__default.default.stringify({
|
|
@@ -1325,7 +1326,7 @@ function createGithubWebhookAction(options) {
|
|
|
1325
1326
|
return pluginScaffolderNode.createTemplateAction({
|
|
1326
1327
|
id: "github:webhook",
|
|
1327
1328
|
description: "Creates webhook for a repository on GitHub.",
|
|
1328
|
-
examples: examples$
|
|
1329
|
+
examples: examples$6,
|
|
1329
1330
|
supportsDryRun: true,
|
|
1330
1331
|
schema: {
|
|
1331
1332
|
input: {
|
|
@@ -1443,7 +1444,7 @@ function createGithubWebhookAction(options) {
|
|
|
1443
1444
|
});
|
|
1444
1445
|
}
|
|
1445
1446
|
|
|
1446
|
-
const examples$
|
|
1447
|
+
const examples$5 = [
|
|
1447
1448
|
{
|
|
1448
1449
|
description: "Example 1: Create and store a Deploy Key",
|
|
1449
1450
|
example: yaml__default.default.stringify({
|
|
@@ -1468,7 +1469,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1468
1469
|
return pluginScaffolderNode.createTemplateAction({
|
|
1469
1470
|
id: "github:deployKey:create",
|
|
1470
1471
|
description: "Creates and stores Deploy Keys",
|
|
1471
|
-
examples: examples$
|
|
1472
|
+
examples: examples$5,
|
|
1472
1473
|
schema: {
|
|
1473
1474
|
input: {
|
|
1474
1475
|
type: "object",
|
|
@@ -1571,7 +1572,7 @@ function createGithubDeployKeyAction(options) {
|
|
|
1571
1572
|
});
|
|
1572
1573
|
}
|
|
1573
1574
|
|
|
1574
|
-
const examples$
|
|
1575
|
+
const examples$4 = [
|
|
1575
1576
|
{
|
|
1576
1577
|
description: "Create a GitHub Environment (No Policies, No Variables, No Secrets)",
|
|
1577
1578
|
example: yaml__default.default.stringify({
|
|
@@ -1656,7 +1657,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1656
1657
|
return pluginScaffolderNode.createTemplateAction({
|
|
1657
1658
|
id: "github:environment:create",
|
|
1658
1659
|
description: "Creates Deployment Environments",
|
|
1659
|
-
examples: examples$
|
|
1660
|
+
examples: examples$4,
|
|
1660
1661
|
schema: {
|
|
1661
1662
|
input: {
|
|
1662
1663
|
type: "object",
|
|
@@ -1826,7 +1827,7 @@ function createGithubEnvironmentAction(options) {
|
|
|
1826
1827
|
});
|
|
1827
1828
|
}
|
|
1828
1829
|
|
|
1829
|
-
const examples$
|
|
1830
|
+
const examples$3 = [
|
|
1830
1831
|
{
|
|
1831
1832
|
description: "Create a pull request",
|
|
1832
1833
|
example: yaml__default.default.stringify({
|
|
@@ -2110,7 +2111,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2110
2111
|
} = options;
|
|
2111
2112
|
return pluginScaffolderNode.createTemplateAction({
|
|
2112
2113
|
id: "publish:github:pull-request",
|
|
2113
|
-
examples: examples$
|
|
2114
|
+
examples: examples$3,
|
|
2114
2115
|
supportsDryRun: true,
|
|
2115
2116
|
schema: {
|
|
2116
2117
|
input: {
|
|
@@ -2394,7 +2395,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
2394
2395
|
}
|
|
2395
2396
|
};
|
|
2396
2397
|
|
|
2397
|
-
const examples$
|
|
2398
|
+
const examples$2 = [
|
|
2398
2399
|
{
|
|
2399
2400
|
description: "Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.",
|
|
2400
2401
|
example: yaml__default.default.stringify({
|
|
@@ -2449,7 +2450,7 @@ function createPublishGithubAction(options) {
|
|
|
2449
2450
|
return pluginScaffolderNode.createTemplateAction({
|
|
2450
2451
|
id: "publish:github",
|
|
2451
2452
|
description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
|
|
2452
|
-
examples: examples$
|
|
2453
|
+
examples: examples$2,
|
|
2453
2454
|
schema: {
|
|
2454
2455
|
input: {
|
|
2455
2456
|
type: "object",
|
|
@@ -2616,7 +2617,7 @@ function createPublishGithubAction(options) {
|
|
|
2616
2617
|
});
|
|
2617
2618
|
}
|
|
2618
2619
|
|
|
2619
|
-
const examples = [
|
|
2620
|
+
const examples$1 = [
|
|
2620
2621
|
{
|
|
2621
2622
|
description: "GitHub alphanumric autolink reference",
|
|
2622
2623
|
example: yaml__default.default.stringify({
|
|
@@ -2641,7 +2642,7 @@ function createGithubAutolinksAction(options) {
|
|
|
2641
2642
|
return pluginScaffolderNode.createTemplateAction({
|
|
2642
2643
|
id: "github:autolinks:create",
|
|
2643
2644
|
description: "Create an autolink reference for a repository",
|
|
2644
|
-
examples,
|
|
2645
|
+
examples: examples$1,
|
|
2645
2646
|
schema: {
|
|
2646
2647
|
input: {
|
|
2647
2648
|
type: "object",
|
|
@@ -2702,6 +2703,106 @@ function createGithubAutolinksAction(options) {
|
|
|
2702
2703
|
});
|
|
2703
2704
|
}
|
|
2704
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
|
+
|
|
2705
2806
|
const githubModule = backendPluginApi.createBackendModule({
|
|
2706
2807
|
pluginId: "scaffolder",
|
|
2707
2808
|
moduleId: "github",
|
|
@@ -2751,6 +2852,10 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
2751
2852
|
integrations,
|
|
2752
2853
|
githubCredentialsProvider,
|
|
2753
2854
|
config
|
|
2855
|
+
}),
|
|
2856
|
+
createGithubPagesEnableAction({
|
|
2857
|
+
integrations,
|
|
2858
|
+
githubCredentialsProvider
|
|
2754
2859
|
})
|
|
2755
2860
|
);
|
|
2756
2861
|
}
|
|
@@ -2763,6 +2868,7 @@ exports.createGithubAutolinksAction = createGithubAutolinksAction;
|
|
|
2763
2868
|
exports.createGithubDeployKeyAction = createGithubDeployKeyAction;
|
|
2764
2869
|
exports.createGithubEnvironmentAction = createGithubEnvironmentAction;
|
|
2765
2870
|
exports.createGithubIssuesLabelAction = createGithubIssuesLabelAction;
|
|
2871
|
+
exports.createGithubPagesEnableAction = createGithubPagesEnableAction;
|
|
2766
2872
|
exports.createGithubRepoCreateAction = createGithubRepoCreateAction;
|
|
2767
2873
|
exports.createGithubRepoPushAction = createGithubRepoPushAction;
|
|
2768
2874
|
exports.createGithubWebhookAction = createGithubWebhookAction;
|