@backstage/plugin-scaffolder-backend-module-github 0.8.2-next.1 → 0.8.3-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 +20 -0
- package/dist/actions/gitHelpers.cjs.js.map +1 -1
- package/dist/actions/gitHubEnvironment.examples.cjs.js.map +1 -1
- package/dist/actions/github.cjs.js.map +1 -1
- package/dist/actions/github.examples.cjs.js.map +1 -1
- package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
- package/dist/actions/githubActionsDispatch.examples.cjs.js.map +1 -1
- package/dist/actions/githubAutolinks.cjs.js.map +1 -1
- package/dist/actions/githubAutolinks.examples.cjs.js.map +1 -1
- package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
- package/dist/actions/githubBranchProtection.examples.cjs.js.map +1 -1
- package/dist/actions/githubDeployKey.cjs.js.map +1 -1
- package/dist/actions/githubDeployKey.examples.cjs.js.map +1 -1
- package/dist/actions/githubEnvironment.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.examples.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.examples.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -1
- package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
- package/dist/actions/githubRepoCreate.examples.cjs.js.map +1 -1
- package/dist/actions/githubRepoPush.cjs.js.map +1 -1
- package/dist/actions/githubRepoPush.examples.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.examples.cjs.js.map +1 -1
- package/dist/actions/helpers.cjs.js.map +1 -1
- package/dist/actions/inputProperties.cjs.js.map +1 -1
- package/dist/actions/outputProperties.cjs.js.map +1 -1
- package/dist/autocomplete/autocomplete.cjs.js.map +1 -1
- package/dist/module.cjs.js.map +1 -1
- package/dist/util.cjs.js.map +1 -1
- package/package.json +8 -8
|
@@ -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 { Entity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\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 catalog: CatalogService;\n}) {\n const { integrations, catalog } = 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 id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n name: z =>\n z.string({\n description: `Name of the deployment environment to create`,\n }),\n deploymentBranchPolicy: z =>\n z\n .object(\n {\n protected_branches: z.boolean({\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 }),\n custom_branch_policies: z.boolean({\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 }),\n },\n {\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n },\n )\n .optional(),\n customBranchPolicyNames: z =>\n z\n .array(z.string(), {\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 })\n .optional(),\n customTagPolicyNames: z =>\n z\n .array(z.string(), {\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 })\n .optional(),\n environmentVariables: z =>\n z\n .record(z.string(), {\n description: `Environment variables attached to the deployment environment`,\n })\n .optional(),\n secrets: z =>\n z\n .record(z.string(), {\n description: `Secrets attached to the deployment environment`,\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n waitTimer: z =>\n z\n .number({\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n })\n .optional(),\n preventSelfReview: z =>\n z\n .boolean({\n description:\n 'Whether to prevent self-review for this environment',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n })\n .optional(),\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 // 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 const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\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 catalog.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n credentials: await ctx.getInitiatorCredentials(),\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":";;;;;;;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,OAAA,EAAY,GAAA,OAAA;AAGlC,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,iCAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,CACP,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH,CAAA;AAAA,QACH,IAAA,EAAM,CACJ,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WAAa,EAAA,CAAA,4CAAA;AAAA,SACd,CAAA;AAAA,QACH,sBAAA,EAAwB,OACtB,CACG,CAAA,MAAA;AAAA,UACC;AAAA,YACE,kBAAA,EAAoB,EAAE,OAAQ,CAAA;AAAA,cAC5B,WACE,EAAA;AAAA,aACH,CAAA;AAAA,YACD,sBAAA,EAAwB,EAAE,OAAQ,CAAA;AAAA,cAChC,WACE,EAAA;AAAA,aACH;AAAA,WACH;AAAA,UACA;AAAA,YACE,WACE,EAAA;AAAA;AACJ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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;;;;"}
|
|
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 { Entity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\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 catalog: CatalogService;\n}) {\n const { integrations, catalog } = 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 id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n name: z =>\n z.string({\n description: `Name of the deployment environment to create`,\n }),\n deploymentBranchPolicy: z =>\n z\n .object(\n {\n protected_branches: z.boolean({\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 }),\n custom_branch_policies: z.boolean({\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 }),\n },\n {\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n },\n )\n .optional(),\n customBranchPolicyNames: z =>\n z\n .array(z.string(), {\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 })\n .optional(),\n customTagPolicyNames: z =>\n z\n .array(z.string(), {\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 })\n .optional(),\n environmentVariables: z =>\n z\n .record(z.string(), {\n description: `Environment variables attached to the deployment environment`,\n })\n .optional(),\n secrets: z =>\n z\n .record(z.string(), {\n description: `Secrets attached to the deployment environment`,\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n waitTimer: z =>\n z\n .number({\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n })\n .optional(),\n preventSelfReview: z =>\n z\n .boolean({\n description:\n 'Whether to prevent self-review for this environment',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n })\n .optional(),\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 // 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 const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\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 catalog.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n credentials: await ctx.getInitiatorCredentials(),\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":";;;;;;;;;;;;;AAkCO,SAAS,8BAA8B,OAAA,EAG3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,OAAA,EAAQ,GAAI,OAAA;AAGlC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,2BAAA;AAAA,IACJ,WAAA,EAAa,iCAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,4CAAA;AA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AG;AAClD,UAAA,MAAM,YAAA,GAAeA,uBAAA,CAAO,WAAA,CAAY,KAAK,CAAA;AAC7C,UAAA,MAAM,wBAAwBA,uBAAA,CAAO,eAAA;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACF;AACA,UAAA,MAAM,wBAAwBA,uBAAA,CAAO,SAAA;AAAA,YACnC,qBAAA;AAAA,YACAA,wBAAO,eAAA,CAAgB;AAAA,WACzB;AAEA,UAAA,MAAM,IAAI,UAAA,CAAW;AAAA,YACnB,GAAA,EAAK,+BAA+B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,EAAI,IAAI,IAAI,GAAG,CAAA,CAAA;AAAA,YAChE,IAAI,YAAY;AACd,cAAA,MAAM,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,+BAAA,CAAgC;AAAA,gBACxD,aAAA,EAAe,YAAA;AAAA,gBACf,KAAA;AAAA,gBACA,IAAA;AAAA,gBACA,gBAAA,EAAkB,IAAA;AAAA,gBAClB,WAAA,EAAa,GAAA;AAAA,gBACb,eAAA,EAAiB,qBAAA;AAAA,gBACjB,MAAA,EAAQ;AAAA,eACT,CAAA;AAAA,YACH;AAAA,WACD,CAAA;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -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 id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n number: z =>\n z.number({\n description: 'The pull request or issue number to add labels to',\n }),\n labels: z =>\n z.array(z.string(), {\n description: 'The labels to add to the pull request or issue',\n }),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\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 octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\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","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,
|
|
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 id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n number: z =>\n z.number({\n description: 'The pull request or issue number to add labels to',\n }),\n labels: z =>\n z.array(z.string(), {\n description: 'The labels to add to the pull request or issue',\n }),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\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 octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\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","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAAA,EAG3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,IACJ,WAAA,EAAa,mDAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,QAAQ,CAAA,CAAA,KACN,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAC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,MAAA,CAAO,IAAA;AAAA,UACT,oCAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC9E;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubIssuesLabel.examples.cjs.js","sources":["../../src/actions/githubIssuesLabel.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Add labels to pull request or issue',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:label',\n name: 'Add labels to pull request or issue',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n number: '1',\n labels: ['bug'],\n },\n },\n ],\n }),\n },\n {\n description: 'Add labels to pull request or issue with specific token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:label',\n name: 'Add labels to pull request or issue with token',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n number: '1',\n labels: ['bug', 'documentation'],\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,
|
|
1
|
+
{"version":3,"file":"githubIssuesLabel.examples.cjs.js","sources":["../../src/actions/githubIssuesLabel.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Add labels to pull request or issue',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:label',\n name: 'Add labels to pull request or issue',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n number: '1',\n labels: ['bug'],\n },\n },\n ],\n }),\n },\n {\n description: 'Add labels to pull request or issue with specific token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:label',\n name: 'Add labels to pull request or issue with token',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n number: '1',\n labels: ['bug', 'documentation'],\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,qCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,qBAAA;AAAA,UACR,IAAA,EAAM,qCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,MAAA,EAAQ,GAAA;AAAA,YACR,MAAA,EAAQ,CAAC,KAAK;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,yDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,qBAAA;AAAA,UACR,IAAA,EAAM,gDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,MAAA,EAAQ,GAAA;AAAA,YACR,MAAA,EAAQ,CAAC,KAAA,EAAO,eAAe,CAAA;AAAA,YAC/B,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -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 id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n buildType: z =>\n z\n .enum(['legacy', 'workflow'], {\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n })\n .default('workflow')\n .optional(),\n sourceBranch: z =>\n z\n .string({\n description: 'The GitHub Pages source branch. Default is \"main\"',\n })\n .default('main')\n .optional(),\n sourcePath: z =>\n z\n .enum(['/', '/docs'], {\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n })\n .default('/')\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\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({\n ...octokitOptions,\n log: ctx.logger,\n });\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,
|
|
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 id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n buildType: z =>\n z\n .enum(['legacy', 'workflow'], {\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n })\n .default('workflow')\n .optional(),\n sourceBranch: z =>\n z\n .string({\n description: 'The GitHub Pages source branch. Default is \"main\"',\n })\n .default('main')\n .optional(),\n sourcePath: z =>\n z\n .enum(['/', '/docs'], {\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n })\n .default('/')\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\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({\n ...octokitOptions,\n log: ctx.logger,\n });\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,OAAA,EAG3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,cACJC,mCAAA;AAAA,IACA,WAAA,EAAa,wCAAA;AAAA,IACb,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,WAAW,CAAA,CAAA,KACT,CAAA,CACG,KAAK,CAAC,QAAA,EAAU,UAAU,CAAA,EAAG;AAAA,UAC5B,WAAA,EACE;AAAA,SACH,CAAA,CACA,OAAA,CAAQ,UAAU,EAClB,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,CAAA,CACA,OAAA,CAAQ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,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,qBAAA,EAAwB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC1C,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,QAAQ,kCAAA,EAAoC;AAAA,YACvD,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAA,EAAY,SAAA;AAAA,YACZ,MAAA,EAAQ;AAAA,cACN,MAAA,EAAQ,YAAA;AAAA,cACR,IAAA,EAAM;AAAA,aACR;AAAA,YACA,OAAA,EAAS;AAAA,cACP,sBAAA,EAAwB;AAAA;AAC1B,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAAA,IACnD;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPagesEnable.examples.cjs.js","sources":["../../src/actions/githubPagesEnable.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Enables GitHub Pages for a repository.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages',\n name: 'Enable GitHub Pages',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom source path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-path',\n name: 'Enable GitHub Pages with Custom Source Path',\n input: {\n repoUrl: 'github.com?repo=customPathRepo&owner=customOwner',\n sourcePath: '/docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository using legacy build type.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-legacy',\n name: 'Enable GitHub Pages with Legacy Build Type',\n input: {\n repoUrl: 'github.com?repo=legacyRepo&owner=legacyOwner',\n buildType: 'legacy',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom source branch.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-branch',\n name: 'Enable GitHub Pages with Custom Source Branch',\n input: {\n repoUrl: 'github.com?repo=customBranchRepo&owner=branchOwner',\n sourceBranch: 'develop',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n\n {\n description:\n 'Enables GitHub Pages for a repository with full customization.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-full-custom',\n name: 'Enable GitHub Pages with Full Customization',\n input: {\n repoUrl: 'github.com?repo=fullCustomRepo&owner=customOwner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with minimal configuration.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-minimal',\n name: 'Enable GitHub Pages with Minimal Configuration',\n input: {\n repoUrl: 'github.com?repo=minimalRepo&owner=minimalOwner',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with custom build type and source path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-build-path',\n name: 'Enable GitHub Pages with Custom Build Type and Source Path',\n input: {\n repoUrl: 'github.com?repo=customBuildPathRepo&owner=customOwner',\n buildType: 'legacy',\n sourcePath: '/custom-path',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with custom source branch and path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-branch-path',\n name: 'Enable GitHub Pages with Custom Source Branch and Path',\n input: {\n repoUrl:\n 'github.com?repo=customBranchPathRepo&owner=branchPathOwner',\n sourceBranch: 'feature-branch',\n sourcePath: '/project-docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom owner and repository name.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-owner-repo',\n name: 'Enable GitHub Pages with Custom Owner and Repository Name',\n input: {\n repoUrl: 'github.com?repo=customRepoName&owner=customOwnerName',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with full customization and a different token.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-full-custom-diff-token',\n name: 'Enable GitHub Pages with Full Customization and Different Token',\n input: {\n repoUrl: 'github.com?repo=customTokenRepo&owner=tokenOwner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/site',\n token: 'gph_DifferentGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a specific token for authorization.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-specific-token',\n name: 'Enable GitHub Pages with Specific Token',\n input: {\n repoUrl: 'github.com?repo=specificTokenRepo&owner=tokenOwner',\n token: 'gph_SpecificGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a documentation site with custom configuration.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-doc-site',\n name: 'Enable GitHub Pages for Documentation Site',\n input: {\n repoUrl: 'github.com?repo=docSiteRepo&owner=docsOwner',\n buildType: 'workflow',\n sourceBranch: 'docs-branch',\n sourcePath: '/docs-site',\n token: 'gph_DocsGitHubToken',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,EAAI,EAAA,cAAA;AAAA,UACJ,IAAM,EAAA,qBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,UAAA;AAAA,YACX,YAAc,EAAA,MAAA;AAAA,YACd,UAAY,EAAA,GAAA;AAAA,YACZ,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,kEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,EAAI,EAAA,0BAAA;AAAA,UACJ,IAAM,EAAA,6CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kDAAA;AAAA,YACT,UAAY,EAAA,OAAA;AAAA,YACZ,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,gEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,E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AAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,EAAI,EAAA,qCAAA;AAAA,UACJ,IAAM,EAAA,iEAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kDAAA;AAAA,YACT,SAAW,EAAA,UAAA;AAAA,YACX,YAAc,EAAA,MAAA;AAAA,YACd,UAAY,EAAA,OAAA;AAAA,YACZ,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,gFAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,EAAI,EAAA,6BAAA;AAAA,UACJ,IAAM,EAAA,yCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,oDAAA;AAAA,YACT,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,cAAA;AAAA,UACR,EAAI,EAAA,uBAAA;AAAA,UACJ,IAAM,EAAA,4CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,6CAAA;AAAA,YACT,SAAW,EAAA,UAAA;AAAA,YACX,YAAc,EAAA,aAAA;AAAA,YACd,UAAY,EAAA,YAAA;AAAA,YACZ,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"githubPagesEnable.examples.cjs.js","sources":["../../src/actions/githubPagesEnable.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Enables GitHub Pages for a repository.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages',\n name: 'Enable GitHub Pages',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom source path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-path',\n name: 'Enable GitHub Pages with Custom Source Path',\n input: {\n repoUrl: 'github.com?repo=customPathRepo&owner=customOwner',\n sourcePath: '/docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository using legacy build type.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-legacy',\n name: 'Enable GitHub Pages with Legacy Build Type',\n input: {\n repoUrl: 'github.com?repo=legacyRepo&owner=legacyOwner',\n buildType: 'legacy',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom source branch.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-branch',\n name: 'Enable GitHub Pages with Custom Source Branch',\n input: {\n repoUrl: 'github.com?repo=customBranchRepo&owner=branchOwner',\n sourceBranch: 'develop',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n\n {\n description:\n 'Enables GitHub Pages for a repository with full customization.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-full-custom',\n name: 'Enable GitHub Pages with Full Customization',\n input: {\n repoUrl: 'github.com?repo=fullCustomRepo&owner=customOwner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with minimal configuration.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-minimal',\n name: 'Enable GitHub Pages with Minimal Configuration',\n input: {\n repoUrl: 'github.com?repo=minimalRepo&owner=minimalOwner',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with custom build type and source path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-build-path',\n name: 'Enable GitHub Pages with Custom Build Type and Source Path',\n input: {\n repoUrl: 'github.com?repo=customBuildPathRepo&owner=customOwner',\n buildType: 'legacy',\n sourcePath: '/custom-path',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with custom source branch and path.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-branch-path',\n name: 'Enable GitHub Pages with Custom Source Branch and Path',\n input: {\n repoUrl:\n 'github.com?repo=customBranchPathRepo&owner=branchPathOwner',\n sourceBranch: 'feature-branch',\n sourcePath: '/project-docs',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a custom owner and repository name.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-custom-owner-repo',\n name: 'Enable GitHub Pages with Custom Owner and Repository Name',\n input: {\n repoUrl: 'github.com?repo=customRepoName&owner=customOwnerName',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with full customization and a different token.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-full-custom-diff-token',\n name: 'Enable GitHub Pages with Full Customization and Different Token',\n input: {\n repoUrl: 'github.com?repo=customTokenRepo&owner=tokenOwner',\n buildType: 'workflow',\n sourceBranch: 'main',\n sourcePath: '/site',\n token: 'gph_DifferentGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a repository with a specific token for authorization.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-specific-token',\n name: 'Enable GitHub Pages with Specific Token',\n input: {\n repoUrl: 'github.com?repo=specificTokenRepo&owner=tokenOwner',\n token: 'gph_SpecificGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Enables GitHub Pages for a documentation site with custom configuration.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:pages',\n id: 'github-pages-doc-site',\n name: 'Enable GitHub Pages for Documentation Site',\n input: {\n repoUrl: 'github.com?repo=docSiteRepo&owner=docsOwner',\n buildType: 'workflow',\n sourceBranch: 'docs-branch',\n sourcePath: '/docs-site',\n token: 'gph_DocsGitHubToken',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,cAAA;AAAA,UACR,EAAA,EAAI,cAAA;AAAA,UACJ,IAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,UAAA;AAAA,YACX,YAAA,EAAc,MAAA;AAAA,YACd,UAAA,EAAY,GAAA;AAAA,YACZ,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,kEAAA;A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ACR,EAAA,EAAI,uBAAA;AAAA,UACJ,IAAA,EAAM,4CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,6CAAA;AAAA,YACT,SAAA,EAAW,UAAA;AAAA,YACX,YAAA,EAAc,aAAA;AAAA,YACd,UAAA,EAAY,YAAA;AAAA,YACZ,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.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 path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport {\n createPullRequest,\n DELETE_FILE,\n} from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { JsonValue } from '@backstage/types';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n branchName: z =>\n z.string({\n description: 'The name for the branch',\n }),\n filesToDelete: z =>\n z\n .array(z.string(), {\n description: 'List of files that will be deleted',\n })\n .optional(),\n targetBranchName: z =>\n z\n .string({\n description: 'The target branch name of the pull request',\n })\n .optional(),\n title: z =>\n z.string({\n description: 'The name for the pull request',\n }),\n description: z =>\n z.string({\n description: 'The description of the pull request',\n }),\n draft: z =>\n z\n .boolean({\n description: 'Create a draft pull request',\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as reviewers to the pull request',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as assignees to the pull request',\n })\n .optional(),\n teamReviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The teams that will be added as reviewers to the pull request',\n })\n .optional(),\n commitMessage: z =>\n z\n .string({\n description: 'The commit message for the pull request commit',\n })\n .optional(),\n update: z =>\n z\n .boolean({\n description: 'Update pull request if already exists',\n })\n .optional(),\n forceFork: z =>\n z\n .boolean({\n description: 'Create pull request from a fork',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n })\n .optional(),\n forceEmptyGitAuthor: z =>\n z\n .boolean({\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n })\n .optional(),\n createWhenEmpty: z =>\n z\n .boolean({\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n })\n .optional(),\n },\n output: {\n targetBranchName: z =>\n z.string({\n description: 'Target branch name of the merge request',\n }),\n remoteUrl: z =>\n z.string({\n description: 'Link to the pull request in Github',\n }),\n pullRequestNumber: z =>\n z.number({\n description: 'The pull request number',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n filesToDelete,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n assignees,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries([\n ...directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n // order of arrays is important so filesToDelete will overwrite\n // changes from files above\n ...(filesToDelete || []).map(filePath => [\n targetPath ? path.posix.join(targetPath, filePath) : filePath,\n DELETE_FILE,\n ]),\n ]);\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n const pullRequest = { owner, repo, number: pullRequestNumber };\n if (reviewers || teamReviewers) {\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n if (assignees) {\n if (assignees.length > 10) {\n ctx.logger.warn(\n 'Assignees list is too long, only the first 10 will be used.',\n );\n }\n await addAssigneesToPullRequest(\n pullRequest,\n assignees,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function addAssigneesToPullRequest(\n pr: GithubPullRequest,\n assignees: string[],\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.issues.addAssignees({\n owner: pr.owner,\n repo: pr.repo,\n issue_number: pr.number,\n assignees,\n });\n\n const addedAssignees = result.data.assignees?.join(', ') ?? '';\n\n logger.info(\n `Added assignees [${addedAssignees}] to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding assignees to Pull request ${pr.number}`,\n e,\n );\n }\n }\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path","DELETE_FILE"],"mappings":";;;;;;;;;;;;;;;AA4CA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ;AAAA,GACnC,CAAA;AACH;AAsDW,MAAA,oCAAA,GAAuC,CAClD,OACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,YAAA;AAAA,IACA,yBAAA;AAAA,IACA,aAAgB,GAAA,oBAAA;AAAA,IAChB;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,OAAOC,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,6BAAA;AAAA,cACJC,mCAAA;AAAA,IACA,c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AAA,IAAA;AAAA,YACL,gBAAgB,UAAU,CAAA,aAAA,EAAgB,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,WACjG;AAAA;AACF,OACD,CAAA;AAAA,aACM,CAAG,EAAA;AACV,MAAO,MAAA,CAAA,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA;AACF;AAEJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.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 path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport {\n createPullRequest,\n DELETE_FILE,\n} from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { JsonValue } from '@backstage/types';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 }),\n branchName: z =>\n z.string({\n description: 'The name for the branch',\n }),\n filesToDelete: z =>\n z\n .array(z.string(), {\n description: 'List of files that will be deleted',\n })\n .optional(),\n targetBranchName: z =>\n z\n .string({\n description: 'The target branch name of the pull request',\n })\n .optional(),\n title: z =>\n z.string({\n description: 'The name for the pull request',\n }),\n description: z =>\n z.string({\n description: 'The description of the pull request',\n }),\n draft: z =>\n z\n .boolean({\n description: 'Create a draft pull request',\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as reviewers to the pull request',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as assignees to the pull request',\n })\n .optional(),\n teamReviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The teams that will be added as reviewers to the pull request',\n })\n .optional(),\n commitMessage: z =>\n z\n .string({\n description: 'The commit message for the pull request commit',\n })\n .optional(),\n update: z =>\n z\n .boolean({\n description: 'Update pull request if already exists',\n })\n .optional(),\n forceFork: z =>\n z\n .boolean({\n description: 'Create pull request from a fork',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n })\n .optional(),\n forceEmptyGitAuthor: z =>\n z\n .boolean({\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n })\n .optional(),\n createWhenEmpty: z =>\n z\n .boolean({\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n })\n .optional(),\n },\n output: {\n targetBranchName: z =>\n z.string({\n description: 'Target branch name of the merge request',\n }),\n remoteUrl: z =>\n z.string({\n description: 'Link to the pull request in Github',\n }),\n pullRequestNumber: z =>\n z.number({\n description: 'The pull request number',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n filesToDelete,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n assignees,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries([\n ...directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n // order of arrays is important so filesToDelete will overwrite\n // changes from files above\n ...(filesToDelete || []).map(filePath => [\n targetPath ? path.posix.join(targetPath, filePath) : filePath,\n DELETE_FILE,\n ]),\n ]);\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n const pullRequest = { owner, repo, number: pullRequestNumber };\n if (reviewers || teamReviewers) {\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n if (assignees) {\n if (assignees.length > 10) {\n ctx.logger.warn(\n 'Assignees list is too long, only the first 10 will be used.',\n );\n }\n await addAssigneesToPullRequest(\n pullRequest,\n assignees,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function addAssigneesToPullRequest(\n pr: GithubPullRequest,\n assignees: string[],\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.issues.addAssignees({\n owner: pr.owner,\n repo: pr.repo,\n issue_number: pr.number,\n assignees,\n });\n\n const addedAssignees = result.data.assignees?.join(', ') ?? '';\n\n logger.info(\n `Added assignees [${addedAssignees}] to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding assignees to Pull request ${pr.number}`,\n e,\n );\n }\n }\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path","DELETE_FILE"],"mappings":";;;;;;;;;;;;;;;AA4CA,MAAM,4BAA4BA,sBAAA,CAAgB;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA,GAAO,YAAA;AAAA,EACP,KAAA,EAAO;AACT,CAAA,KAAM;AACJ,EAAA,MAAM,cAAA,GAAiB,MAAMC,sBAAA,CAAkB;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAA,EAAqB,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,EAAO;AAAA,GACR,CAAA;AAED,EAAA,MAAM,SAAA,GAAYC,eAAA,CAAQ,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAA,CAAU;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAM;AAAE,GACnC,CAAA;AACH;AAsDK,MAAM,oCAAA,GAAuC,CAClD,OAAA,KACG;AACH,EAAA,MAAM;AAAA,IACJ,YAAA;AAAA,IACA,yBAAA;AAAA,IACA,aAAA,GAAgB,oBAAA;AAAA,IAChB;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,6BAAA;AAAA,cACJC,mCAAA;AAAA,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AAA;AAClE,UAAA,MAAM,aAAa,MAAA,CAAO,IAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,IAAI,CAAA,IAAK,EAAA;AAE9D,UAAA,MAAA,CAAO,IAAA;AAAA,YACL,gBAAgB,UAAU,CAAA,aAAA,EAAgB,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,WACjG;AAAA,QACF;AAAA,OACD,CAAA;AAAA,IACH,SAAS,CAAA,EAAG;AACV,MAAA,MAAA,CAAO,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPullRequest.examples.cjs.js","sources":["../../src/actions/githubPullRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target branch name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target branch name',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request as draft',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request as draft',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n draft: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetPath: 'targetPath',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with source path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with source path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n sourcePath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n reviewers: ['foobar'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with team reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with team reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n teamReviewers: ['team-foo'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with commit message',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n commitMessage: 'Custom commit message',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name and email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorEmail will be 'scaffolder@backstage.io'\n // once one author attribute has been set we need to set both\n gitAuthorName: 'Foo Bar',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorName will be 'Scaffolder'\n // once one author attribute has been set we need to set both\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Do not create empty pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n createWhenEmpty: false,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with all parameters',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n draft: true,\n targetPath: 'targetPath',\n sourcePath: 'source',\n token: 'gph_YourGitHubToken',\n reviewers: ['foobar'],\n teamReviewers: ['team-foo'],\n commitMessage: 'Commit for foo changes',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n createWhenEmpty: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with assignees',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n assignees: ['foobar'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,uBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,+CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,+CAAA;AAAA,UACN,KAAO,EAAA;AAAA,Y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AA,qBAAA;AAAA,YACP,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,YACpB,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,YAC1B,aAAe,EAAA,wBAAA;AAAA,YACf,aAAe,EAAA,SAAA;AAAA,YACf,cAAgB,EAAA,iBAAA;AAAA,YAChB,eAAiB,EAAA;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,sCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,sCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,SAAA,EAAW,CAAC,QAAQ;AAAA;AACtB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"githubPullRequest.examples.cjs.js","sources":["../../src/actions/githubPullRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target branch name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target branch name',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request as draft',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request as draft',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n draft: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetPath: 'targetPath',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with source path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with source path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n sourcePath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n reviewers: ['foobar'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with team reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with team reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n teamReviewers: ['team-foo'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with commit message',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n commitMessage: 'Custom commit message',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name and email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorEmail will be 'scaffolder@backstage.io'\n // once one author attribute has been set we need to set both\n gitAuthorName: 'Foo Bar',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorName will be 'Scaffolder'\n // once one author attribute has been set we need to set both\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Do not create empty pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n createWhenEmpty: false,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with all parameters',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n draft: true,\n targetPath: 'targetPath',\n sourcePath: 'source',\n token: 'gph_YourGitHubToken',\n reviewers: ['foobar'],\n teamReviewers: ['team-foo'],\n commitMessage: 'Commit for foo changes',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n createWhenEmpty: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with assignees',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n assignees: ['foobar'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,6BAAA;AAAA,UACR,IAAA,EAAM,uBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,SAAA;AAAA,YACZ,KAAA,EAAO,mBAAA;AAAA,YACP,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;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A,YACZ,KAAA,EAAO,mBAAA;AAAA,YACP,WAAA,EAAa,wBAAA;AAAA,YACb,gBAAA,EAAkB,MAAA;AAAA,YAClB,KAAA,EAAO,IAAA;AAAA,YACP,UAAA,EAAY,YAAA;AAAA,YACZ,UAAA,EAAY,QAAA;AAAA,YACZ,KAAA,EAAO,qBAAA;AAAA,YACP,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,YACpB,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,YAC1B,aAAA,EAAe,wBAAA;AAAA,YACf,aAAA,EAAe,SAAA;AAAA,YACf,cAAA,EAAgB,iBAAA;AAAA,YAChB,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,sCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,6BAAA;AAAA,UACR,IAAA,EAAM,sCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,SAAA;AAAA,YACZ,KAAA,EAAO,mBAAA;AAAA,YACP,WAAA,EAAa,wBAAA;AAAA,YACb,SAAA,EAAW,CAAC,QAAQ;AAAA;AACtB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubRepoCreate.cjs.js","sources":["../../src/actions/githubRepoCreate.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 GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { createGithubRepoWithCollaboratorsAndTopics } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoCreate.examples';\n\n/**\n * Creates a new action that initializes a git repository\n *\n * @public\n */\nexport function createGithubRepoCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n repoVisibility: inputProps.repoVisibility,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n repoVisibility = 'private',\n deleteBranchOnMerge = false,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\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({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n return newRepo.clone_url;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.requireCodeOwnerReviews","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.repoVisibility","inputProps.deleteBranchOnMerge","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings":";;;;;;;;;;;AAqCO,SAAS,6BAA6B,OAG1C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,oBAAA;AAAA,IACJ,WAAa,EAAA,8BAAA;AAAA,cACbC,kCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,yBAAyBC,uCAAW;AAAA,QACpC,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,6BAA6BC,2CAAW;AAAA,QACxC,6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OAAA;AAAA,YACA,SAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAA;AAAA,YACA,OAAA;AAAA,YACA,iBAAA;AAAA,YACA,gBAAA;AAAA,YACA,SAAA;AAAA,YACA,GAAI,CAAA;AAAA,WACN;AACA,UAAA,OAAO,OAAQ,CAAA,SAAA;AAAA;AACjB,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AAAA;AACnC,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"githubRepoCreate.cjs.js","sources":["../../src/actions/githubRepoCreate.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 GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { createGithubRepoWithCollaboratorsAndTopics } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoCreate.examples';\n\n/**\n * Creates a new action that initializes a git repository\n *\n * @public\n */\nexport function createGithubRepoCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n repoVisibility: inputProps.repoVisibility,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n repoVisibility = 'private',\n deleteBranchOnMerge = false,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\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({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n return newRepo.clone_url;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.requireCodeOwnerReviews","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.repoVisibility","inputProps.deleteBranchOnMerge","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings":";;;;;;;;;;;AAqCO,SAAS,6BAA6B,OAAA,EAG1C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,oBAAA;AAAA,IACJ,WAAA,EAAa,8BAAA;AAAA,cACbC,kCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,yBAAyBC,uCAAW;AAAA,QACpC,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,gBAAgBC,8BAAW;AAAA,QAC3B,qBAAqBC,mCAAW;AAAA,QAChC,kBAAkBC,gCAAW;AAAA,QAC7B,kBAAkBC,gCAAW;AAAA,QAC7B,wBAAwBC,sCAAW;AAAA,QACnC,0BAA0BC,wCAAW;AAAA,QACrC,kBAAkBC,gCAAW;AAAA,QAC7B,gBAAgBC,8BAAW;AAAA,QAC3B,mBAAmBC,iCAAW;AAAA,QAC9B,eAAeC,6BAAW;AAAA,QAC1B,aAAaC,2BAAW;AAAA,QACxB,SAASC,uBAAW;AAAA,QACpB,WAAWC,yBAAW;AAAA,QACtB,OAAOC,qBAAW;AAAA,QAClB,QAAQC,sBAAW;AAAA,QACnB,eAAeC,6BAAW;AAAA,QAC1B,SAASC,uBAAW;AAAA,QACpB,mBAAmBC,iCAAW;AAAA,QAC9B,uBAAu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