@backstage/plugin-scaffolder-backend-module-github 0.5.0-next.2 → 0.5.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 +42 -0
- package/dist/index.cjs.js +123 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/package.json +12 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.5.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 094eaa3: Remove references to in-repo backend-common
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-scaffolder-node@0.5.0-next.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.0.1-next.0
|
|
11
|
+
- @backstage/catalog-client@1.7.0
|
|
12
|
+
- @backstage/catalog-model@1.7.0
|
|
13
|
+
- @backstage/config@1.2.0
|
|
14
|
+
- @backstage/errors@1.2.4
|
|
15
|
+
- @backstage/integration@1.15.0
|
|
16
|
+
|
|
17
|
+
## 0.5.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 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.
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 22a19e6: Added the ability for the actions `publish:github` and `github:repo:create` to take inputs for 'custom properties' for organization repositories.
|
|
30
|
+
- 162cdf4: Update dependency @octokit/webhooks to 10.9.2 due to SNYK-JS-OCTOKITWEBHOOKS-6129527
|
|
31
|
+
- 7976081: Added support for all request parameters in the Github create/update environment API in the Github environment create scaffolder action.
|
|
32
|
+
|
|
33
|
+
Disable MultiEntityPicker when `maxItems` limit is reached defined in `JSONSchema`
|
|
34
|
+
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
- @backstage/backend-common@0.25.0
|
|
37
|
+
- @backstage/backend-plugin-api@1.0.0
|
|
38
|
+
- @backstage/catalog-model@1.7.0
|
|
39
|
+
- @backstage/catalog-client@1.7.0
|
|
40
|
+
- @backstage/integration@1.15.0
|
|
41
|
+
- @backstage/config@1.2.0
|
|
42
|
+
- @backstage/errors@1.2.4
|
|
43
|
+
- @backstage/plugin-scaffolder-node@0.4.11
|
|
44
|
+
|
|
3
45
|
## 0.5.0-next.2
|
|
4
46
|
|
|
5
47
|
### 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
|
|
|
@@ -2767,11 +2768,59 @@ const examples$4 = [
|
|
|
2767
2768
|
}
|
|
2768
2769
|
]
|
|
2769
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
|
+
})
|
|
2770
2819
|
}
|
|
2771
2820
|
];
|
|
2772
2821
|
|
|
2773
2822
|
function createGithubEnvironmentAction(options) {
|
|
2774
|
-
const { integrations } = options;
|
|
2823
|
+
const { integrations, catalogClient } = options;
|
|
2775
2824
|
return pluginScaffolderNode.createTemplateAction({
|
|
2776
2825
|
id: "github:environment:create",
|
|
2777
2826
|
description: "Creates Deployment Environments",
|
|
@@ -2843,6 +2892,24 @@ function createGithubEnvironmentAction(options) {
|
|
|
2843
2892
|
title: "Authentication Token",
|
|
2844
2893
|
type: "string",
|
|
2845
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
|
+
}
|
|
2846
2913
|
}
|
|
2847
2914
|
}
|
|
2848
2915
|
}
|
|
@@ -2856,8 +2923,12 @@ function createGithubEnvironmentAction(options) {
|
|
|
2856
2923
|
customTagPolicyNames,
|
|
2857
2924
|
environmentVariables,
|
|
2858
2925
|
secrets,
|
|
2859
|
-
token: providedToken
|
|
2926
|
+
token: providedToken,
|
|
2927
|
+
waitTimer,
|
|
2928
|
+
preventSelfReview,
|
|
2929
|
+
reviewers
|
|
2860
2930
|
} = ctx.input;
|
|
2931
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
2861
2932
|
const octokitOptions = await getOctokitOptions({
|
|
2862
2933
|
integrations,
|
|
2863
2934
|
token: providedToken,
|
|
@@ -2872,11 +2943,52 @@ function createGithubEnvironmentAction(options) {
|
|
|
2872
2943
|
owner,
|
|
2873
2944
|
repo
|
|
2874
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
|
+
}
|
|
2875
2984
|
await client.rest.repos.createOrUpdateEnvironment({
|
|
2876
2985
|
owner,
|
|
2877
2986
|
repo,
|
|
2878
2987
|
environment_name: name,
|
|
2879
|
-
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
|
|
2880
2992
|
});
|
|
2881
2993
|
if (customBranchPolicyNames) {
|
|
2882
2994
|
for (const item of customBranchPolicyNames) {
|
|
@@ -4125,11 +4237,15 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
4125
4237
|
registerInit({
|
|
4126
4238
|
deps: {
|
|
4127
4239
|
scaffolder: alpha.scaffolderActionsExtensionPoint,
|
|
4128
|
-
config: backendPluginApi.coreServices.rootConfig
|
|
4240
|
+
config: backendPluginApi.coreServices.rootConfig,
|
|
4241
|
+
discovery: backendPluginApi.coreServices.discovery
|
|
4129
4242
|
},
|
|
4130
|
-
async init({ scaffolder, config }) {
|
|
4243
|
+
async init({ scaffolder, config, discovery }) {
|
|
4131
4244
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
4132
4245
|
const githubCredentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
|
|
4246
|
+
const catalogClient$1 = new catalogClient.CatalogClient({
|
|
4247
|
+
discoveryApi: discovery
|
|
4248
|
+
});
|
|
4133
4249
|
scaffolder.addActions(
|
|
4134
4250
|
createGithubActionsDispatchAction({
|
|
4135
4251
|
integrations,
|
|
@@ -4143,7 +4259,8 @@ const githubModule = backendPluginApi.createBackendModule({
|
|
|
4143
4259
|
integrations
|
|
4144
4260
|
}),
|
|
4145
4261
|
createGithubEnvironmentAction({
|
|
4146
|
-
integrations
|
|
4262
|
+
integrations,
|
|
4263
|
+
catalogClient: catalogClient$1
|
|
4147
4264
|
}),
|
|
4148
4265
|
createGithubIssuesLabelAction({
|
|
4149
4266
|
integrations,
|