@backstage/plugin-scaffolder-backend-module-github 0.5.0-next.1 → 0.5.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 +41 -0
- package/dist/index.cjs.js +140 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d425fc4: **BREAKING**: The return values from `createBackendPlugin`, `createBackendModule`, and `createServiceFactory` are now simply `BackendFeature` and `ServiceFactory`, instead of the previously deprecated form of a function that returns them. For this reason, `createServiceFactory` also no longer accepts the callback form where you provide direct options to the service. This also affects all `coreServices.*` service refs.
|
|
8
|
+
|
|
9
|
+
This may in particular affect tests; if you were effectively doing `createBackendModule({...})()` (note the parentheses), you can now remove those extra parentheses at the end. You may encounter cases of this in your `packages/backend/src/index.ts` too, where you add plugins, modules, and services. If you were using `createServiceFactory` with a function as its argument for the purpose of passing in options, this pattern has been deprecated for a while and is no longer supported. You may want to explore the new multiton patterns to achieve your goals, or moving settings to app-config.
|
|
10
|
+
|
|
11
|
+
As part of this change, the `IdentityFactoryOptions` type was removed, and can no longer be used to tweak that service. The identity service was also deprecated some time ago, and you will want to [migrate to the new auth system](https://backstage.io/docs/tutorials/auth-service-migration) if you still rely on it.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 22a19e6: Added the ability for the actions `publish:github` and `github:repo:create` to take inputs for 'custom properties' for organization repositories.
|
|
16
|
+
- 162cdf4: Update dependency @octokit/webhooks to 10.9.2 due to SNYK-JS-OCTOKITWEBHOOKS-6129527
|
|
17
|
+
- 7976081: Added support for all request parameters in the Github create/update environment API in the Github environment create scaffolder action.
|
|
18
|
+
|
|
19
|
+
Disable MultiEntityPicker when `maxItems` limit is reached defined in `JSONSchema`
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/backend-common@0.25.0
|
|
23
|
+
- @backstage/backend-plugin-api@1.0.0
|
|
24
|
+
- @backstage/catalog-model@1.7.0
|
|
25
|
+
- @backstage/catalog-client@1.7.0
|
|
26
|
+
- @backstage/integration@1.15.0
|
|
27
|
+
- @backstage/config@1.2.0
|
|
28
|
+
- @backstage/errors@1.2.4
|
|
29
|
+
- @backstage/plugin-scaffolder-node@0.4.11
|
|
30
|
+
|
|
31
|
+
## 0.5.0-next.2
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 22a19e6: Added the ability for the actions `publish:github` and `github:repo:create` to take inputs for 'custom properties' for organization repositories.
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @backstage/backend-common@0.25.0-next.2
|
|
38
|
+
- @backstage/backend-plugin-api@1.0.0-next.2
|
|
39
|
+
- @backstage/integration@1.15.0-next.0
|
|
40
|
+
- @backstage/config@1.2.0
|
|
41
|
+
- @backstage/errors@1.2.4
|
|
42
|
+
- @backstage/plugin-scaffolder-node@0.4.11-next.2
|
|
43
|
+
|
|
3
44
|
## 0.5.0-next.1
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -14,6 +14,7 @@ var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request
|
|
|
14
14
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
15
15
|
var pluginScaffolderBackendModuleGithub = require('@backstage/plugin-scaffolder-backend-module-github');
|
|
16
16
|
var alpha = require('@backstage/plugin-scaffolder-node/alpha');
|
|
17
|
+
var catalogClient = require('@backstage/catalog-client');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
19
20
|
|
|
@@ -144,7 +145,7 @@ async function getOctokitOptions(options) {
|
|
|
144
145
|
previews: ["nebula-preview"]
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, repoVariables, secrets, oidcCustomization, logger) {
|
|
148
|
+
async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, repoVariables, secrets, oidcCustomization, customProperties, logger) {
|
|
148
149
|
const user = await client.rest.users.getByUsername({
|
|
149
150
|
username: owner
|
|
150
151
|
});
|
|
@@ -168,7 +169,9 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
|
|
|
168
169
|
homepage,
|
|
169
170
|
has_projects: hasProjects,
|
|
170
171
|
has_wiki: hasWiki,
|
|
171
|
-
has_issues: hasIssues
|
|
172
|
+
has_issues: hasIssues,
|
|
173
|
+
// Custom properties only available on org repos
|
|
174
|
+
custom_properties: customProperties
|
|
172
175
|
}) : client.rest.repos.createForAuthenticatedUser({
|
|
173
176
|
name: repo,
|
|
174
177
|
private: repoVisibility === "private",
|
|
@@ -883,6 +886,11 @@ const oidcCustomization = {
|
|
|
883
886
|
}
|
|
884
887
|
}
|
|
885
888
|
};
|
|
889
|
+
const customProperties = {
|
|
890
|
+
title: "Custom Repository Properties",
|
|
891
|
+
description: "Custom properties to be added to the repository (note, this only works for organization repositories)",
|
|
892
|
+
type: "object"
|
|
893
|
+
};
|
|
886
894
|
|
|
887
895
|
const remoteUrl = {
|
|
888
896
|
title: "A URL to the repository with the provider",
|
|
@@ -1890,7 +1898,8 @@ function createGithubRepoCreateAction(options) {
|
|
|
1890
1898
|
repoVariables: repoVariables,
|
|
1891
1899
|
secrets: secrets,
|
|
1892
1900
|
oidcCustomization: oidcCustomization,
|
|
1893
|
-
requiredCommitSigning: requiredCommitSigning
|
|
1901
|
+
requiredCommitSigning: requiredCommitSigning,
|
|
1902
|
+
customProperties: customProperties
|
|
1894
1903
|
}
|
|
1895
1904
|
},
|
|
1896
1905
|
output: {
|
|
@@ -1923,6 +1932,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
1923
1932
|
repoVariables,
|
|
1924
1933
|
secrets,
|
|
1925
1934
|
oidcCustomization,
|
|
1935
|
+
customProperties,
|
|
1926
1936
|
token: providedToken
|
|
1927
1937
|
} = ctx.input;
|
|
1928
1938
|
const octokitOptions = await getOctokitOptions({
|
|
@@ -1959,6 +1969,7 @@ function createGithubRepoCreateAction(options) {
|
|
|
1959
1969
|
repoVariables,
|
|
1960
1970
|
secrets,
|
|
1961
1971
|
oidcCustomization,
|
|
1972
|
+
customProperties,
|
|
1962
1973
|
ctx.logger
|
|
1963
1974
|
);
|
|
1964
1975
|
ctx.output("remoteUrl", newRepo.clone_url);
|
|
@@ -2757,11 +2768,59 @@ const examples$4 = [
|
|
|
2757
2768
|
}
|
|
2758
2769
|
]
|
|
2759
2770
|
})
|
|
2771
|
+
},
|
|
2772
|
+
{
|
|
2773
|
+
description: "Create a GitHub Environment with Wait Timer",
|
|
2774
|
+
example: yaml__default.default.stringify({
|
|
2775
|
+
steps: [
|
|
2776
|
+
{
|
|
2777
|
+
action: "github:environment:create",
|
|
2778
|
+
name: "Create Environment",
|
|
2779
|
+
input: {
|
|
2780
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
2781
|
+
name: "envname",
|
|
2782
|
+
waitTimer: 1e3
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
]
|
|
2786
|
+
})
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
description: "Create a GitHub Environment with Prevent Self Review",
|
|
2790
|
+
example: yaml__default.default.stringify({
|
|
2791
|
+
steps: [
|
|
2792
|
+
{
|
|
2793
|
+
action: "github:environment:create",
|
|
2794
|
+
name: "Create Environment",
|
|
2795
|
+
input: {
|
|
2796
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
2797
|
+
name: "envname",
|
|
2798
|
+
preventSelfReview: true
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
]
|
|
2802
|
+
})
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
description: "Create a GitHub Environment with Reviewers",
|
|
2806
|
+
example: yaml__default.default.stringify({
|
|
2807
|
+
steps: [
|
|
2808
|
+
{
|
|
2809
|
+
action: "github:environment:create",
|
|
2810
|
+
name: "Create Environment",
|
|
2811
|
+
input: {
|
|
2812
|
+
repoUrl: "github.com?repo=repository&owner=owner",
|
|
2813
|
+
name: "envname",
|
|
2814
|
+
reviewers: ["group:default/team-a", "user:default/johndoe"]
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
]
|
|
2818
|
+
})
|
|
2760
2819
|
}
|
|
2761
2820
|
];
|
|
2762
2821
|
|
|
2763
2822
|
function createGithubEnvironmentAction(options) {
|
|
2764
|
-
const { integrations } = options;
|
|
2823
|
+
const { integrations, catalogClient } = options;
|
|
2765
2824
|
return pluginScaffolderNode.createTemplateAction({
|
|
2766
2825
|
id: "github:environment:create",
|
|
2767
2826
|
description: "Creates Deployment Environments",
|
|
@@ -2833,6 +2892,24 @@ function createGithubEnvironmentAction(options) {
|
|
|
2833
2892
|
title: "Authentication Token",
|
|
2834
2893
|
type: "string",
|
|
2835
2894
|
description: "The token to use for authorization to GitHub"
|
|
2895
|
+
},
|
|
2896
|
+
waitTimer: {
|
|
2897
|
+
title: "Wait Timer",
|
|
2898
|
+
type: "integer",
|
|
2899
|
+
description: "The time to wait before creating or updating the environment (in milliseconds)"
|
|
2900
|
+
},
|
|
2901
|
+
preventSelfReview: {
|
|
2902
|
+
title: "Prevent Self Review",
|
|
2903
|
+
type: "boolean",
|
|
2904
|
+
description: "Whether to prevent self-review for this environment"
|
|
2905
|
+
},
|
|
2906
|
+
reviewers: {
|
|
2907
|
+
title: "Reviewers",
|
|
2908
|
+
type: "array",
|
|
2909
|
+
description: "Reviewers for this environment",
|
|
2910
|
+
items: {
|
|
2911
|
+
type: "string"
|
|
2912
|
+
}
|
|
2836
2913
|
}
|
|
2837
2914
|
}
|
|
2838
2915
|
}
|
|
@@ -2846,8 +2923,12 @@ function createGithubEnvironmentAction(options) {
|
|
|
2846
2923
|
customTagPolicyNames,
|
|
2847
2924
|
environmentVariables,
|
|
2848
2925
|
secrets,
|
|
2849
|
-
token: providedToken
|
|
2926
|
+
token: providedToken,
|
|
2927
|
+
waitTimer,
|
|
2928
|
+
preventSelfReview,
|
|
2929
|
+
reviewers
|
|
2850
2930
|
} = ctx.input;
|
|
2931
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
2851
2932
|
const octokitOptions = await getOctokitOptions({
|
|
2852
2933
|
integrations,
|
|
2853
2934
|
token: providedToken,
|
|
@@ -2862,11 +2943,52 @@ function createGithubEnvironmentAction(options) {
|
|
|
2862
2943
|
owner,
|
|
2863
2944
|
repo
|
|
2864
2945
|
});
|
|
2946
|
+
const githubReviewers = [];
|
|
2947
|
+
if (reviewers) {
|
|
2948
|
+
let reviewersEntityRefs = [];
|
|
2949
|
+
const catalogResponse = await catalogClient?.getEntitiesByRefs({
|
|
2950
|
+
entityRefs: reviewers
|
|
2951
|
+
});
|
|
2952
|
+
if (catalogResponse?.items?.length) {
|
|
2953
|
+
reviewersEntityRefs = catalogResponse.items;
|
|
2954
|
+
}
|
|
2955
|
+
for (const reviewerEntityRef of reviewersEntityRefs) {
|
|
2956
|
+
if (reviewerEntityRef?.kind === "User") {
|
|
2957
|
+
try {
|
|
2958
|
+
const user = await client.rest.users.getByUsername({
|
|
2959
|
+
username: reviewerEntityRef.metadata.name
|
|
2960
|
+
});
|
|
2961
|
+
githubReviewers.push({
|
|
2962
|
+
type: "User",
|
|
2963
|
+
id: user.data.id
|
|
2964
|
+
});
|
|
2965
|
+
} catch (error) {
|
|
2966
|
+
ctx.logger.error("User not found:", error);
|
|
2967
|
+
}
|
|
2968
|
+
} else if (reviewerEntityRef?.kind === "Group") {
|
|
2969
|
+
try {
|
|
2970
|
+
const team = await client.rest.teams.getByName({
|
|
2971
|
+
org: owner,
|
|
2972
|
+
team_slug: reviewerEntityRef.metadata.name
|
|
2973
|
+
});
|
|
2974
|
+
githubReviewers.push({
|
|
2975
|
+
type: "Team",
|
|
2976
|
+
id: team.data.id
|
|
2977
|
+
});
|
|
2978
|
+
} catch (error) {
|
|
2979
|
+
ctx.logger.error("Team not found:", error);
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2865
2984
|
await client.rest.repos.createOrUpdateEnvironment({
|
|
2866
2985
|
owner,
|
|
2867
2986
|
repo,
|
|
2868
2987
|
environment_name: name,
|
|
2869
|
-
deployment_branch_policy: deploymentBranchPolicy ?? null
|
|
2988
|
+
deployment_branch_policy: deploymentBranchPolicy ?? null,
|
|
2989
|
+
wait_timer: waitTimer ?? 0,
|
|
2990
|
+
prevent_self_review: preventSelfReview ?? false,
|
|
2991
|
+
reviewers: githubReviewers.length ? githubReviewers : null
|
|
2870
2992
|
});
|
|
2871
2993
|
if (customBranchPolicyNames) {
|
|
2872
2994
|
for (const item of customBranchPolicyNames) {
|
|
@@ -3603,7 +3725,8 @@ function createPublishGithubAction(options) {
|
|
|
3603
3725
|
repoVariables: repoVariables,
|
|
3604
3726
|
secrets: secrets,
|
|
3605
3727
|
oidcCustomization: oidcCustomization,
|
|
3606
|
-
requiredCommitSigning: requiredCommitSigning
|
|
3728
|
+
requiredCommitSigning: requiredCommitSigning,
|
|
3729
|
+
customProperties: customProperties
|
|
3607
3730
|
}
|
|
3608
3731
|
},
|
|
3609
3732
|
output: {
|
|
@@ -3653,6 +3776,7 @@ function createPublishGithubAction(options) {
|
|
|
3653
3776
|
secrets,
|
|
3654
3777
|
oidcCustomization,
|
|
3655
3778
|
token: providedToken,
|
|
3779
|
+
customProperties,
|
|
3656
3780
|
requiredCommitSigning = false
|
|
3657
3781
|
} = ctx.input;
|
|
3658
3782
|
const octokitOptions = await getOctokitOptions({
|
|
@@ -3689,6 +3813,7 @@ function createPublishGithubAction(options) {
|
|
|
3689
3813
|
repoVariables,
|
|
3690
3814
|
secrets,
|
|
3691
3815
|
oidcCustomization,
|
|
3816
|
+
customProperties,
|
|
3692
3817
|
ctx.logger
|
|
3693
3818
|
);
|
|
3694
3819
|
const remoteUrl = newRepo.clone_url;
|
|
@@ -4112,11 +4237,15 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
4112
4237
|
registerInit({
|
|
4113
4238
|
deps: {
|
|
4114
4239
|
scaffolder: alpha.scaffolderActionsExtensionPoint,
|
|
4115
|
-
config: backendPluginApi.coreServices.rootConfig
|
|
4240
|
+
config: backendPluginApi.coreServices.rootConfig,
|
|
4241
|
+
discovery: backendPluginApi.coreServices.discovery
|
|
4116
4242
|
},
|
|
4117
|
-
async init({ scaffolder, config }) {
|
|
4243
|
+
async init({ scaffolder, config, discovery }) {
|
|
4118
4244
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
4119
4245
|
const githubCredentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
|
|
4246
|
+
const catalogClient$1 = new catalogClient.CatalogClient({
|
|
4247
|
+
discoveryApi: discovery
|
|
4248
|
+
});
|
|
4120
4249
|
scaffolder.addActions(
|
|
4121
4250
|
createGithubActionsDispatchAction({
|
|
4122
4251
|
integrations,
|
|
@@ -4130,7 +4259,8 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
4130
4259
|
integrations
|
|
4131
4260
|
}),
|
|
4132
4261
|
createGithubEnvironmentAction({
|
|
4133
|
-
integrations
|
|
4262
|
+
integrations,
|
|
4263
|
+
catalogClient: catalogClient$1
|
|
4134
4264
|
}),
|
|
4135
4265
|
createGithubIssuesLabelAction({
|
|
4136
4266
|
integrations,
|