@backstage/plugin-scaffolder-backend-module-github 0.6.1-next.1 → 0.6.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 +37 -0
- package/dist/actions/githubEnvironment.cjs.js +103 -51
- package/dist/actions/githubEnvironment.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.cjs.js +10 -5
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.cjs.js +15 -10
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.cjs.js +38 -19
- package/dist/actions/githubPullRequest.cjs.js.map +1 -1
- package/dist/actions/githubRepoCreate.cjs.js +34 -28
- package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
- package/dist/actions/githubRepoPush.cjs.js +34 -28
- package/dist/actions/githubRepoPush.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.cjs.js +16 -11
- package/dist/actions/githubWebhook.cjs.js.map +1 -1
- package/dist/index.d.ts +160 -160
- package/package.json +12 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 11bc3e6: Made "github:pages:enable" action idempotent
|
|
8
|
+
- 3f45e0f: Made "github:environment:create" action idempotent
|
|
9
|
+
- 09cf038: Got rid of most `@backstage/backend-common` usages
|
|
10
|
+
- 8c38687: Made "github:issues:label" action idempotent
|
|
11
|
+
- 89948b2: Made "github:repo:push" action idempotent
|
|
12
|
+
- 9391f58: Pass `undefined` to some parameters for `createOrUpdateEnvironment` as these values are not always supported in different plans of GitHub
|
|
13
|
+
- 8182a59: Made "github:webhook" action idempotent
|
|
14
|
+
- 8f9c54c: Made "github:repo:create" action idempotent
|
|
15
|
+
- 0ae0c77: Made "publish:github:pull-request" action idempotent
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @backstage/integration@1.16.2
|
|
18
|
+
- @backstage/plugin-scaffolder-node@0.8.0
|
|
19
|
+
- @backstage/backend-plugin-api@1.2.1
|
|
20
|
+
- @backstage/catalog-client@1.9.1
|
|
21
|
+
- @backstage/catalog-model@1.7.3
|
|
22
|
+
- @backstage/config@1.3.2
|
|
23
|
+
- @backstage/errors@1.2.7
|
|
24
|
+
- @backstage/types@1.2.1
|
|
25
|
+
|
|
26
|
+
## 0.6.1-next.2
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 9391f58: Pass `undefined` to some parameters for `createOrUpdateEnvironment` as these values are not always supported in different plans of GitHub
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- @backstage/plugin-scaffolder-node@0.8.0-next.2
|
|
33
|
+
- @backstage/integration@1.16.2-next.0
|
|
34
|
+
- @backstage/backend-plugin-api@1.2.1-next.1
|
|
35
|
+
- @backstage/catalog-client@1.9.1
|
|
36
|
+
- @backstage/catalog-model@1.7.3
|
|
37
|
+
- @backstage/config@1.3.2
|
|
38
|
+
- @backstage/errors@1.2.7
|
|
39
|
+
|
|
3
40
|
## 0.6.1-next.1
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -137,9 +137,15 @@ Wildcard characters will not match \`/\`. For example, to match tags that begin
|
|
|
137
137
|
repo
|
|
138
138
|
});
|
|
139
139
|
const client = new octokit.Octokit(octokitOptions);
|
|
140
|
-
const
|
|
141
|
-
owner
|
|
142
|
-
|
|
140
|
+
const repositoryId = await ctx.checkpoint({
|
|
141
|
+
key: `get.repo.${owner}.${repo}`,
|
|
142
|
+
fn: async () => {
|
|
143
|
+
const repository = await client.rest.repos.get({
|
|
144
|
+
owner,
|
|
145
|
+
repo
|
|
146
|
+
});
|
|
147
|
+
return repository.data.id;
|
|
148
|
+
}
|
|
143
149
|
});
|
|
144
150
|
const githubReviewers = [];
|
|
145
151
|
if (reviewers) {
|
|
@@ -158,25 +164,37 @@ Wildcard characters will not match \`/\`. For example, to match tags that begin
|
|
|
158
164
|
for (const reviewerEntityRef of reviewersEntityRefs) {
|
|
159
165
|
if (reviewerEntityRef?.kind === "User") {
|
|
160
166
|
try {
|
|
161
|
-
const
|
|
162
|
-
|
|
167
|
+
const userId = await ctx.checkpoint({
|
|
168
|
+
key: `get.user.${reviewerEntityRef.metadata.name}`,
|
|
169
|
+
fn: async () => {
|
|
170
|
+
const user = await client.rest.users.getByUsername({
|
|
171
|
+
username: reviewerEntityRef.metadata.name
|
|
172
|
+
});
|
|
173
|
+
return user.data.id;
|
|
174
|
+
}
|
|
163
175
|
});
|
|
164
176
|
githubReviewers.push({
|
|
165
177
|
type: "User",
|
|
166
|
-
id:
|
|
178
|
+
id: userId
|
|
167
179
|
});
|
|
168
180
|
} catch (error) {
|
|
169
181
|
ctx.logger.error("User not found:", error);
|
|
170
182
|
}
|
|
171
183
|
} else if (reviewerEntityRef?.kind === "Group") {
|
|
172
184
|
try {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
185
|
+
const teamId = await ctx.checkpoint({
|
|
186
|
+
key: `get.team.${reviewerEntityRef.metadata.name}`,
|
|
187
|
+
fn: async () => {
|
|
188
|
+
const team = await client.rest.teams.getByName({
|
|
189
|
+
org: owner,
|
|
190
|
+
team_slug: reviewerEntityRef.metadata.name
|
|
191
|
+
});
|
|
192
|
+
return team.data.id;
|
|
193
|
+
}
|
|
176
194
|
});
|
|
177
195
|
githubReviewers.push({
|
|
178
196
|
type: "Team",
|
|
179
|
-
id:
|
|
197
|
+
id: teamId
|
|
180
198
|
});
|
|
181
199
|
} catch (error) {
|
|
182
200
|
ctx.logger.error("Team not found:", error);
|
|
@@ -184,57 +202,86 @@ Wildcard characters will not match \`/\`. For example, to match tags that begin
|
|
|
184
202
|
}
|
|
185
203
|
}
|
|
186
204
|
}
|
|
187
|
-
await
|
|
188
|
-
owner
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
deployment_branch_policy: deploymentBranchPolicy ?? null,
|
|
192
|
-
wait_timer: waitTimer ?? 0,
|
|
193
|
-
prevent_self_review: preventSelfReview ?? false,
|
|
194
|
-
reviewers: githubReviewers.length ? githubReviewers : null
|
|
195
|
-
});
|
|
196
|
-
if (customBranchPolicyNames) {
|
|
197
|
-
for (const item of customBranchPolicyNames) {
|
|
198
|
-
await client.rest.repos.createDeploymentBranchPolicy({
|
|
205
|
+
await ctx.checkpoint({
|
|
206
|
+
key: `create.or.update.environment.${owner}.${repo}.${name}`,
|
|
207
|
+
fn: async () => {
|
|
208
|
+
await client.rest.repos.createOrUpdateEnvironment({
|
|
199
209
|
owner,
|
|
200
210
|
repo,
|
|
201
|
-
type: "branch",
|
|
202
211
|
environment_name: name,
|
|
203
|
-
|
|
212
|
+
deployment_branch_policy: deploymentBranchPolicy ?? void 0,
|
|
213
|
+
wait_timer: waitTimer ?? void 0,
|
|
214
|
+
prevent_self_review: preventSelfReview ?? void 0,
|
|
215
|
+
reviewers: githubReviewers.length ? githubReviewers : void 0
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
if (customBranchPolicyNames) {
|
|
220
|
+
for (const item of customBranchPolicyNames) {
|
|
221
|
+
await ctx.checkpoint({
|
|
222
|
+
key: `create.deployment.branch.policy.branch.${owner}.${repo}.${name}.${item}`,
|
|
223
|
+
fn: async () => {
|
|
224
|
+
await client.rest.repos.createDeploymentBranchPolicy({
|
|
225
|
+
owner,
|
|
226
|
+
repo,
|
|
227
|
+
type: "branch",
|
|
228
|
+
environment_name: name,
|
|
229
|
+
name: item
|
|
230
|
+
});
|
|
231
|
+
}
|
|
204
232
|
});
|
|
205
233
|
}
|
|
206
234
|
}
|
|
207
235
|
if (customTagPolicyNames) {
|
|
208
236
|
for (const item of customTagPolicyNames) {
|
|
209
|
-
await
|
|
210
|
-
owner
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
237
|
+
await ctx.checkpoint({
|
|
238
|
+
key: `create.deployment.branch.policy.tag.${owner}.${repo}.${name}.${item}`,
|
|
239
|
+
fn: async () => {
|
|
240
|
+
await client.rest.repos.createDeploymentBranchPolicy({
|
|
241
|
+
owner,
|
|
242
|
+
repo,
|
|
243
|
+
type: "tag",
|
|
244
|
+
environment_name: name,
|
|
245
|
+
name: item
|
|
246
|
+
});
|
|
247
|
+
}
|
|
215
248
|
});
|
|
216
249
|
}
|
|
217
250
|
}
|
|
218
251
|
for (const [key, value] of Object.entries(environmentVariables ?? {})) {
|
|
219
|
-
await
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
252
|
+
await ctx.checkpoint({
|
|
253
|
+
key: `create.env.variable.${owner}.${repo}.${name}.${key}`,
|
|
254
|
+
fn: async () => {
|
|
255
|
+
await client.rest.actions.createEnvironmentVariable({
|
|
256
|
+
repository_id: repositoryId,
|
|
257
|
+
owner,
|
|
258
|
+
repo,
|
|
259
|
+
environment_name: name,
|
|
260
|
+
name: key,
|
|
261
|
+
value
|
|
262
|
+
});
|
|
263
|
+
}
|
|
226
264
|
});
|
|
227
265
|
}
|
|
228
266
|
if (secrets) {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
267
|
+
const { publicKey, publicKeyId } = await ctx.checkpoint({
|
|
268
|
+
key: `get.env.public.key.${owner}.${repo}.${name}`,
|
|
269
|
+
fn: async () => {
|
|
270
|
+
const publicKeyResponse = await client.rest.actions.getEnvironmentPublicKey({
|
|
271
|
+
repository_id: repositoryId,
|
|
272
|
+
owner,
|
|
273
|
+
repo,
|
|
274
|
+
environment_name: name
|
|
275
|
+
});
|
|
276
|
+
return {
|
|
277
|
+
publicKey: publicKeyResponse.data.key,
|
|
278
|
+
publicKeyId: publicKeyResponse.data.key_id
|
|
279
|
+
};
|
|
280
|
+
}
|
|
234
281
|
});
|
|
235
282
|
await Sodium__default.default.ready;
|
|
236
283
|
const binaryKey = Sodium__default.default.from_base64(
|
|
237
|
-
|
|
284
|
+
publicKey,
|
|
238
285
|
Sodium__default.default.base64_variants.ORIGINAL
|
|
239
286
|
);
|
|
240
287
|
for (const [key, value] of Object.entries(secrets)) {
|
|
@@ -247,14 +294,19 @@ Wildcard characters will not match \`/\`. For example, to match tags that begin
|
|
|
247
294
|
encryptedBinarySecret,
|
|
248
295
|
Sodium__default.default.base64_variants.ORIGINAL
|
|
249
296
|
);
|
|
250
|
-
await
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
297
|
+
await ctx.checkpoint({
|
|
298
|
+
key: `create.or.update.env.secret.${owner}.${repo}.${name}.${key}`,
|
|
299
|
+
fn: async () => {
|
|
300
|
+
await client.rest.actions.createOrUpdateEnvironmentSecret({
|
|
301
|
+
repository_id: repositoryId,
|
|
302
|
+
owner,
|
|
303
|
+
repo,
|
|
304
|
+
environment_name: name,
|
|
305
|
+
secret_name: key,
|
|
306
|
+
encrypted_value: encryptedBase64Secret,
|
|
307
|
+
key_id: publicKeyId
|
|
308
|
+
});
|
|
309
|
+
}
|
|
258
310
|
});
|
|
259
311
|
}
|
|
260
312
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubEnvironment.cjs.js","sources":["../../src/actions/githubEnvironment.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './gitHubEnvironment.examples';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { Entity } from '@backstage/catalog-model';\nimport { AuthService } from '@backstage/backend-plugin-api';\n\n/**\n * Creates an `github:environment:create` Scaffolder action that creates a Github Environment.\n *\n * @public\n */\nexport function createGithubEnvironmentAction(options: {\n integrations: ScmIntegrationRegistry;\n catalogClient?: CatalogApi;\n auth?: AuthService;\n}) {\n const { integrations, catalogClient, auth } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction<{\n repoUrl: string;\n name: string;\n deploymentBranchPolicy?: {\n protected_branches: boolean;\n custom_branch_policies: boolean;\n };\n customBranchPolicyNames?: string[];\n customTagPolicyNames?: string[];\n environmentVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n token?: string;\n waitTimer?: number;\n preventSelfReview?: boolean;\n reviewers?: string[];\n }>({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'name'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n name: {\n title: 'Environment Name',\n description: `Name of the deployment environment to create`,\n type: 'string',\n },\n deploymentBranchPolicy: {\n title: 'Deployment Branch Policy',\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n type: 'object',\n required: ['protected_branches', 'custom_branch_policies'],\n properties: {\n protected_branches: {\n title: 'Protected Branches',\n description:\n 'Whether only branches with branch protection rules can deploy to this environment. If `protected_branches` is `true`, `custom_branch_policies` must be `false`; if `protected_branches` is `false`, `custom_branch_policies` must be `true`.',\n type: 'boolean',\n },\n custom_branch_policies: {\n title: 'Custom Branch Policies',\n description:\n 'Whether only branches that match the specified name patterns can deploy to this environment. If `custom_branch_policies` is `true`, `protected_branches` must be `false`; if `custom_branch_policies` is `false`, `protected_branches` must be `true`.',\n type: 'boolean',\n },\n },\n },\n customBranchPolicyNames: {\n title: 'Custom Branch Policy Name',\n description: `The name pattern that branches must match in order to deploy to the environment.\n\nWildcard characters will not match \\`/\\`. For example, to match branches 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.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n customTagPolicyNames: {\n title: 'Custom Tag Policy Name',\n description: `The name pattern that tags must match in order to deploy to the environment.\n\nWildcard 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.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n environmentVariables: {\n title: 'Environment Variables',\n description: `Environment variables attached to the deployment environment`,\n type: 'object',\n },\n secrets: {\n title: 'Deployment Secrets',\n description: `Secrets attached to the deployment environment`,\n type: 'object',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n waitTimer: {\n title: 'Wait Timer',\n type: 'integer',\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n },\n preventSelfReview: {\n title: 'Prevent Self Review',\n type: 'boolean',\n description: 'Whether to prevent self-review for this environment',\n },\n reviewers: {\n title: 'Reviewers',\n type: 'array',\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n name,\n deploymentBranchPolicy,\n customBranchPolicyNames,\n customTagPolicyNames,\n environmentVariables,\n secrets,\n token: providedToken,\n waitTimer,\n preventSelfReview,\n reviewers,\n } = ctx.input;\n\n const { token } = (await auth?.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'catalog',\n })) ?? { token: ctx.secrets?.backstageToken };\n\n // When environment creation step is executed right after a repo publish step, the repository might not be available immediately.\n // Add a 2-second delay before initiating the steps in this action.\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n\n // convert reviewers from catalog entity to Github user or team\n const githubReviewers: { type: 'User' | 'Team'; id: number }[] = [];\n if (reviewers) {\n let reviewersEntityRefs: Array<Entity | undefined> = [];\n // Fetch reviewers from Catalog\n const catalogResponse = await catalogClient?.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n token,\n },\n );\n if (catalogResponse?.items?.length) {\n reviewersEntityRefs = catalogResponse.items;\n }\n\n for (const reviewerEntityRef of reviewersEntityRefs) {\n if (reviewerEntityRef?.kind === 'User') {\n try {\n const user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'User',\n id: user.data.id,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'Team',\n id: team.data.id,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? null,\n wait_timer: waitTimer ?? 0,\n prevent_self_review: preventSelfReview ?? false,\n reviewers: githubReviewers.length ? githubReviewers : null,\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'branch',\n environment_name: name,\n name: item,\n });\n }\n }\n\n if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'tag',\n environment_name: name,\n name: item,\n });\n }\n }\n\n for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n }\n\n if (secrets) {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.key,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAmCO,SAAS,8BAA8B,OAI3C,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,aAAe,EAAA,IAAA,EAAS,GAAA,OAAA;AAG9C,EAAA,OAAOA,yCAeJ,CAAA;AAAA,IACD,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,iCAAA;AAAA,cAC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kBAAkB,IAAK,CAAA,GAAA;AAAA,UACvBA,wBAAO,eAAgB,CAAA;AAAA,SACzB;AACA,QAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,OAAO,CAAG,EAAA;AAClD,UAAM,MAAA,YAAA,GAAeA,uBAAO,CAAA,WAAA,CAAY,KAAK,CAAA;AAC7C,UAAA,MAAM,wBAAwBA,uBAAO,CAAA,eAAA;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACF;AACA,UAAA,MAAM,wBAAwBA,uBAAO,CAAA,SAAA;AAAA,YACnC,qBAAA;AAAA,YACAA,wBAAO,eAAgB,CAAA;AAAA,WACzB;AAEA,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,+BAAgC,CAAA;AAAA,YACxD,aAAA,EAAe,WAAW,IAAK,CAAA,EAAA;AAAA,YAC/B,KAAA;AAAA,YACA,IAAA;AAAA,YACA,gBAAkB,EAAA,IAAA;AAAA,YAClB,WAAa,EAAA,GAAA;AAAA,YACb,eAAiB,EAAA,qBAAA;AAAA,YACjB,MAAA,EAAQ,kBAAkB,IAAK,CAAA;AAAA,WAChC,CAAA;AAAA;AACH;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"githubEnvironment.cjs.js","sources":["../../src/actions/githubEnvironment.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './gitHubEnvironment.examples';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { Entity } from '@backstage/catalog-model';\nimport { AuthService } from '@backstage/backend-plugin-api';\n\n/**\n * Creates an `github:environment:create` Scaffolder action that creates a Github Environment.\n *\n * @public\n */\nexport function createGithubEnvironmentAction(options: {\n integrations: ScmIntegrationRegistry;\n catalogClient?: CatalogApi;\n auth?: AuthService;\n}) {\n const { integrations, catalogClient, auth } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction<{\n repoUrl: string;\n name: string;\n deploymentBranchPolicy?: {\n protected_branches: boolean;\n custom_branch_policies: boolean;\n };\n customBranchPolicyNames?: string[];\n customTagPolicyNames?: string[];\n environmentVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n token?: string;\n waitTimer?: number;\n preventSelfReview?: boolean;\n reviewers?: string[];\n }>({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'name'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n name: {\n title: 'Environment Name',\n description: `Name of the deployment environment to create`,\n type: 'string',\n },\n deploymentBranchPolicy: {\n title: 'Deployment Branch Policy',\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n type: 'object',\n required: ['protected_branches', 'custom_branch_policies'],\n properties: {\n protected_branches: {\n title: 'Protected Branches',\n description:\n 'Whether only branches with branch protection rules can deploy to this environment. If `protected_branches` is `true`, `custom_branch_policies` must be `false`; if `protected_branches` is `false`, `custom_branch_policies` must be `true`.',\n type: 'boolean',\n },\n custom_branch_policies: {\n title: 'Custom Branch Policies',\n description:\n 'Whether only branches that match the specified name patterns can deploy to this environment. If `custom_branch_policies` is `true`, `protected_branches` must be `false`; if `custom_branch_policies` is `false`, `protected_branches` must be `true`.',\n type: 'boolean',\n },\n },\n },\n customBranchPolicyNames: {\n title: 'Custom Branch Policy Name',\n description: `The name pattern that branches must match in order to deploy to the environment.\n\nWildcard characters will not match \\`/\\`. For example, to match branches 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.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n customTagPolicyNames: {\n title: 'Custom Tag Policy Name',\n description: `The name pattern that tags must match in order to deploy to the environment.\n\nWildcard 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.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n environmentVariables: {\n title: 'Environment Variables',\n description: `Environment variables attached to the deployment environment`,\n type: 'object',\n },\n secrets: {\n title: 'Deployment Secrets',\n description: `Secrets attached to the deployment environment`,\n type: 'object',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n waitTimer: {\n title: 'Wait Timer',\n type: 'integer',\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n },\n preventSelfReview: {\n title: 'Prevent Self Review',\n type: 'boolean',\n description: 'Whether to prevent self-review for this environment',\n },\n reviewers: {\n title: 'Reviewers',\n type: 'array',\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n name,\n deploymentBranchPolicy,\n customBranchPolicyNames,\n customTagPolicyNames,\n environmentVariables,\n secrets,\n token: providedToken,\n waitTimer,\n preventSelfReview,\n reviewers,\n } = ctx.input;\n\n const { token } = (await auth?.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'catalog',\n })) ?? { token: ctx.secrets?.backstageToken };\n\n // When environment creation step is executed right after a repo publish step, the repository might not be available immediately.\n // Add a 2-second delay before initiating the steps in this action.\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n\n const repositoryId = await ctx.checkpoint({\n key: `get.repo.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.id;\n },\n });\n\n // convert reviewers from catalog entity to Github user or team\n const githubReviewers: { type: 'User' | 'Team'; id: number }[] = [];\n if (reviewers) {\n let reviewersEntityRefs: Array<Entity | undefined> = [];\n // Fetch reviewers from Catalog\n const catalogResponse = await catalogClient?.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n token,\n },\n );\n if (catalogResponse?.items?.length) {\n reviewersEntityRefs = catalogResponse.items;\n }\n\n for (const reviewerEntityRef of reviewersEntityRefs) {\n if (reviewerEntityRef?.kind === 'User') {\n try {\n const userId = await ctx.checkpoint({\n key: `get.user.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n return user.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'User',\n id: userId,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const teamId = await ctx.checkpoint({\n key: `get.team.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n return team.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'Team',\n id: teamId,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await ctx.checkpoint({\n key: `create.or.update.environment.${owner}.${repo}.${name}`,\n fn: async () => {\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? undefined,\n wait_timer: waitTimer ?? undefined,\n prevent_self_review: preventSelfReview ?? undefined,\n reviewers: githubReviewers.length ? githubReviewers : undefined,\n });\n },\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.branch.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'branch',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.tag.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'tag',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await ctx.checkpoint({\n key: `create.env.variable.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n },\n });\n }\n\n if (secrets) {\n const { publicKey, publicKeyId } = await ctx.checkpoint({\n key: `get.env.public.key.${owner}.${repo}.${name}`,\n fn: async () => {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n return {\n publicKey: publicKeyResponse.data.key,\n publicKeyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKey,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await ctx.checkpoint({\n key: `create.or.update.env.secret.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyId,\n });\n },\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAmCO,SAAS,8BAA8B,OAI3C,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,aAAe,EAAA,IAAA,EAAS,GAAA,OAAA;AAG9C,EAAA,OAAOA,yCAeJ,CAAA;AAAA,IACD,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,iCAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,MAAM,CAAA;AAAA,QAC5B,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,kBAAA;AAAA,YACP,WAAa,EAAA,CAAA,4CAAA,CAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,sBAAwB,EAAA;AAAA,YACtB,KAAO,EAAA,0BAAA;AAAA,YACP,WACE,EAAA,4GAAA;AAAA,YACF,IAAM,EAAA,Q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,UACvB,SAAA;AAAA,UACAA,wBAAO,eAAgB,CAAA;AAAA,SACzB;AACA,QAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,OAAO,CAAG,EAAA;AAClD,UAAM,MAAA,YAAA,GAAeA,uBAAO,CAAA,WAAA,CAAY,KAAK,CAAA;AAC7C,UAAA,MAAM,wBAAwBA,uBAAO,CAAA,eAAA;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACF;AACA,UAAA,MAAM,wBAAwBA,uBAAO,CAAA,SAAA;AAAA,YACnC,qBAAA;AAAA,YACAA,wBAAO,eAAgB,CAAA;AAAA,WACzB;AAEA,UAAA,MAAM,IAAI,UAAW,CAAA;AAAA,YACnB,GAAA,EAAK,+BAA+B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAI,CAAA,EAAA,IAAI,IAAI,GAAG,CAAA,CAAA;AAAA,YAChE,IAAI,YAAY;AACd,cAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,+BAAgC,CAAA;AAAA,gBACxD,aAAe,EAAA,YAAA;AAAA,gBACf,KAAA;AAAA,gBACA,IAAA;AAAA,gBACA,gBAAkB,EAAA,IAAA;AAAA,gBAClB,WAAa,EAAA,GAAA;AAAA,gBACb,eAAiB,EAAA,qBAAA;AAAA,gBACjB,MAAQ,EAAA;AAAA,eACT,CAAA;AAAA;AACH,WACD,CAAA;AAAA;AACH;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -61,11 +61,16 @@ function createGithubIssuesLabelAction(options) {
|
|
|
61
61
|
})
|
|
62
62
|
);
|
|
63
63
|
try {
|
|
64
|
-
await
|
|
65
|
-
owner
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
await ctx.checkpoint({
|
|
65
|
+
key: `github.issues.add.label.${owner}.${repo}.${number}`,
|
|
66
|
+
fn: async () => {
|
|
67
|
+
await client.rest.issues.addLabels({
|
|
68
|
+
owner,
|
|
69
|
+
repo,
|
|
70
|
+
issue_number: number,
|
|
71
|
+
labels
|
|
72
|
+
});
|
|
73
|
+
}
|
|
69
74
|
});
|
|
70
75
|
} catch (e) {
|
|
71
76
|
errors.assertError(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n number: number;\n labels: string[];\n token?: string;\n }>({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'number', 'labels'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n number: {\n title: 'Pull Request or issue number',\n description: 'The pull request or issue number to add labels to',\n type: 'number',\n },\n labels: {\n title: 'Labels',\n description: 'The labels to add to the pull request or issue',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n try {\n await client.rest.issues.addLabels({\n
|
|
1
|
+
{"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n number: number;\n labels: string[];\n token?: string;\n }>({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'number', 'labels'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n number: {\n title: 'Pull Request or issue number',\n description: 'The pull request or issue number to add labels to',\n type: 'number',\n },\n labels: {\n title: 'Labels',\n description: 'The labels to add to the pull request or issue',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n try {\n await ctx.checkpoint({\n key: `github.issues.add.label.${owner}.${repo}.${number}`,\n fn: async () => {\n await client.rest.issues.addLabels({\n owner,\n repo,\n issue_number: number,\n labels,\n });\n },\n });\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAKJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,I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,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAO,EAAA;AAAA,SACR;AAAA,OACH;AAEA,MAAI,IAAA;AACF,QAAA,MAAM,IAAI,UAAW,CAAA;AAAA,UACnB,KAAK,CAA2B,wBAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,IAAI,MAAM,CAAA,CAAA;AAAA,UACvD,IAAI,YAAY;AACd,YAAM,MAAA,MAAA,CAAO,IAAK,CAAA,MAAA,CAAO,SAAU,CAAA;AAAA,cACjC,KAAA;AAAA,cACA,IAAA;AAAA,cACA,YAAc,EAAA,MAAA;AAAA,cACd;AAAA,aACD,CAAA;AAAA;AACH,SACD,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,oCAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC9E;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -74,16 +74,21 @@ function createGithubPagesEnableAction(options) {
|
|
|
74
74
|
ctx.logger.info(
|
|
75
75
|
`Attempting to enable GitHub Pages for ${owner}/${repo} with "${buildType}" build type, on source branch "${sourceBranch}" and source path "${sourcePath}"`
|
|
76
76
|
);
|
|
77
|
-
await
|
|
78
|
-
owner
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
await ctx.checkpoint({
|
|
78
|
+
key: `enabled.github.pages.${owner}.${repo}`,
|
|
79
|
+
fn: async () => {
|
|
80
|
+
await client.request("POST /repos/{owner}/{repo}/pages", {
|
|
81
|
+
owner,
|
|
82
|
+
repo,
|
|
83
|
+
build_type: buildType,
|
|
84
|
+
source: {
|
|
85
|
+
branch: sourceBranch,
|
|
86
|
+
path: sourcePath
|
|
87
|
+
},
|
|
88
|
+
headers: {
|
|
89
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
87
92
|
}
|
|
88
93
|
});
|
|
89
94
|
ctx.logger.info("Completed enabling GitHub Pages");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n buildType: {\n title: 'Build Type',\n type: 'string',\n default: 'workflow',\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n enum: ['legacy', 'workflow'],\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n default: 'main',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n default: '/',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n enum: ['/', '/docs'],\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit(octokitOptions);\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await client.request('POST /repos/{owner}/{repo}/pages', {\n
|
|
1
|
+
{"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n buildType: {\n title: 'Build Type',\n type: 'string',\n default: 'workflow',\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n enum: ['legacy', 'workflow'],\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n default: 'main',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n default: '/',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n enum: ['/', '/docs'],\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit(octokitOptions);\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await ctx.checkpoint({\n key: `enabled.github.pages.${owner}.${repo}`,\n fn: async () => {\n await client.request('POST /repos/{owner}/{repo}/pages', {\n owner: owner,\n repo: repo,\n build_type: buildType,\n source: {\n branch: sourceBranch,\n path: sourcePath,\n },\n headers: {\n 'X-GitHub-Api-Version': '2022-11-28',\n },\n });\n },\n });\n\n ctx.logger.info('Completed enabling GitHub Pages');\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,cACJC,mCAAA;AAAA,IACA,WAAa,EAAA,wCAAA;AAAA,IACb,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,YAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,OAAS,EAAA,UAAA;AAAA,YACT,WACE,EAAA,6EAAA;AAAA,YACF,IAAA,EAAM,CAAC,QAAA,EAAU,UAAU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AA,IAAI,UAAU,SAAS,CAAA,gCAAA,EAAmC,YAAY,CAAA,mBAAA,EAAsB,UAAU,CAAA,CAAA;AAAA,OAC1J;AAEA,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,GAAK,EAAA,CAAA,qBAAA,EAAwB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC1C,IAAI,YAAY;AACd,UAAM,MAAA,MAAA,CAAO,QAAQ,kCAAoC,EAAA;AAAA,YACvD,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAY,EAAA,SAAA;AAAA,YACZ,MAAQ,EAAA;AAAA,cACN,MAAQ,EAAA,YAAA;AAAA,cACR,IAAM,EAAA;AAAA,aACR;AAAA,YACA,OAAS,EAAA;AAAA,cACP,sBAAwB,EAAA;AAAA;AAC1B,WACD,CAAA;AAAA;AACH,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAAA;AACnD,GACD,CAAA;AACH;;;;"}
|
|
@@ -290,15 +290,28 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
290
290
|
if (targetBranchName) {
|
|
291
291
|
createOptions.base = targetBranchName;
|
|
292
292
|
}
|
|
293
|
-
const
|
|
294
|
-
|
|
293
|
+
const pr = await ctx.checkpoint({
|
|
294
|
+
key: `create.pr.${owner}.${repo}.${branchName}`,
|
|
295
|
+
fn: async () => {
|
|
296
|
+
const response = await client.createPullRequest(createOptions);
|
|
297
|
+
if (!response) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
base: response?.data.base,
|
|
302
|
+
html_url: response?.data.html_url,
|
|
303
|
+
number: response?.data.number
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
if (createWhenEmpty === false && !pr) {
|
|
295
308
|
ctx.logger.info("No changes to commit, pull request was not created");
|
|
296
309
|
return;
|
|
297
310
|
}
|
|
298
|
-
if (!
|
|
311
|
+
if (!pr) {
|
|
299
312
|
throw new GithubResponseError("null response from Github");
|
|
300
313
|
}
|
|
301
|
-
const pullRequestNumber =
|
|
314
|
+
const pullRequestNumber = pr.number;
|
|
302
315
|
if (reviewers || teamReviewers) {
|
|
303
316
|
const pullRequest = { owner, repo, number: pullRequestNumber };
|
|
304
317
|
await requestReviewersOnPullRequest(
|
|
@@ -306,32 +319,38 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
306
319
|
reviewers,
|
|
307
320
|
teamReviewers,
|
|
308
321
|
client,
|
|
309
|
-
ctx.logger
|
|
322
|
+
ctx.logger,
|
|
323
|
+
ctx.checkpoint
|
|
310
324
|
);
|
|
311
325
|
}
|
|
312
|
-
const targetBranch =
|
|
326
|
+
const targetBranch = pr.base.ref;
|
|
313
327
|
ctx.output("targetBranchName", targetBranch);
|
|
314
|
-
ctx.output("remoteUrl",
|
|
328
|
+
ctx.output("remoteUrl", pr.html_url);
|
|
315
329
|
ctx.output("pullRequestNumber", pullRequestNumber);
|
|
316
330
|
} catch (e) {
|
|
317
331
|
throw new GithubResponseError("Pull request creation failed", e);
|
|
318
332
|
}
|
|
319
333
|
}
|
|
320
334
|
});
|
|
321
|
-
async function requestReviewersOnPullRequest(pr, reviewers, teamReviewers, client, logger) {
|
|
335
|
+
async function requestReviewersOnPullRequest(pr, reviewers, teamReviewers, client, logger, checkpoint) {
|
|
322
336
|
try {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
337
|
+
await checkpoint({
|
|
338
|
+
key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,
|
|
339
|
+
fn: async () => {
|
|
340
|
+
const result = await client.rest.pulls.requestReviewers({
|
|
341
|
+
owner: pr.owner,
|
|
342
|
+
repo: pr.repo,
|
|
343
|
+
pull_number: pr.number,
|
|
344
|
+
reviewers,
|
|
345
|
+
team_reviewers: teamReviewers ? [...new Set(teamReviewers)] : void 0
|
|
346
|
+
});
|
|
347
|
+
const addedUsers = result.data.requested_reviewers?.join(", ") ?? "";
|
|
348
|
+
const addedTeams = result.data.requested_teams?.join(", ") ?? "";
|
|
349
|
+
logger.info(
|
|
350
|
+
`Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
329
353
|
});
|
|
330
|
-
const addedUsers = result.data.requested_reviewers?.join(", ") ?? "";
|
|
331
|
-
const addedTeams = result.data.requested_teams?.join(", ") ?? "";
|
|
332
|
-
logger.info(
|
|
333
|
-
`Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`
|
|
334
|
-
);
|
|
335
354
|
} catch (e) {
|
|
336
355
|
logger.error(
|
|
337
356
|
`Failure when adding reviewers to Pull request ${pr.number}`,
|