@backstage/plugin-scaffolder-backend-module-github 0.6.1-next.2 → 0.6.2-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.
@@ -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 { createPullRequest } 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';\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 title: string;\n branchName: string;\n targetBranchName?: string;\n description: string;\n repoUrl: string;\n draft?: boolean;\n targetPath?: string;\n sourcePath?: string;\n token?: string;\n reviewers?: string[];\n teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n createWhenEmpty?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the pull request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\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 createWhenEmpty: {\n type: 'boolean',\n title: 'Create When Empty',\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 },\n },\n output: {\n required: [],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\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 );\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 const response = await client.createPullRequest(createOptions);\n\n if (createWhenEmpty === false && !response) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!response) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = response.data.number;\n if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n );\n }\n\n const targetBranch = response.data.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', response.data.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 requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n ) {\n try {\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 ? [...new Set(teamReviewers)] : undefined,\n });\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\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"],"mappings":";;;;;;;;;;;;;;;AAwCA,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,I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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 { createPullRequest } 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 title: string;\n branchName: string;\n targetBranchName?: string;\n description: string;\n repoUrl: string;\n draft?: boolean;\n targetPath?: string;\n sourcePath?: string;\n token?: string;\n reviewers?: string[];\n teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n createWhenEmpty?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the pull request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\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 createWhenEmpty: {\n type: 'boolean',\n title: 'Create When Empty',\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 },\n },\n output: {\n required: [],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\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 );\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 if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\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 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"],"mappings":";;;;;;;;;;;;;;;AAyCA,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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,MAAM,EAAG,CAAA,IAAA;AAAA,YACT,aAAa,EAAG,CAAA,MAAA;AAAA,YAChB,SAAA;AAAA,YACA,cAAA,EAAgB,gBACZ,CAAC,GAAG,IAAI,GAAI,CAAA,aAAa,CAAC,CAC1B,GAAA,KAAA;AAAA,WACL,CAAA;AAED,UAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,mBAAqB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAClE,UAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,eAAiB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAE9D,UAAO,MAAA,CAAA,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;;;;;"}
@@ -101,34 +101,40 @@ function createGithubRepoCreateAction(options) {
101
101
  repo
102
102
  });
103
103
  const client = new octokit.Octokit(octokitOptions);
104
- const newRepo = await helpers.createGithubRepoWithCollaboratorsAndTopics(
105
- client,
106
- repo,
107
- owner,
108
- repoVisibility,
109
- description,
110
- homepage,
111
- deleteBranchOnMerge,
112
- allowMergeCommit,
113
- allowSquashMerge,
114
- squashMergeCommitTitle,
115
- squashMergeCommitMessage,
116
- allowRebaseMerge,
117
- allowAutoMerge,
118
- access,
119
- collaborators,
120
- hasProjects,
121
- hasWiki,
122
- hasIssues,
123
- topics,
124
- repoVariables,
125
- secrets,
126
- oidcCustomization,
127
- customProperties,
128
- subscribe,
129
- ctx.logger
130
- );
131
- ctx.output("remoteUrl", newRepo.clone_url);
104
+ const remoteUrl = await ctx.checkpoint({
105
+ key: `create.repo.and.topics.${owner}.${repo}`,
106
+ fn: async () => {
107
+ const newRepo = await helpers.createGithubRepoWithCollaboratorsAndTopics(
108
+ client,
109
+ repo,
110
+ owner,
111
+ repoVisibility,
112
+ description,
113
+ homepage,
114
+ deleteBranchOnMerge,
115
+ allowMergeCommit,
116
+ allowSquashMerge,
117
+ squashMergeCommitTitle,
118
+ squashMergeCommitMessage,
119
+ allowRebaseMerge,
120
+ allowAutoMerge,
121
+ access,
122
+ collaborators,
123
+ hasProjects,
124
+ hasWiki,
125
+ hasIssues,
126
+ topics,
127
+ repoVariables,
128
+ secrets,
129
+ oidcCustomization,
130
+ customProperties,
131
+ subscribe,
132
+ ctx.logger
133
+ );
134
+ return newRepo.clone_url;
135
+ }
136
+ });
137
+ ctx.output("remoteUrl", remoteUrl);
132
138
  }
133
139
  });
134
140
  }
@@ -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 repoUrl: string;\n description?: string;\n homepage?: string;\n access?: string;\n deleteBranchOnMerge?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n allowRebaseMerge?: boolean;\n allowSquashMerge?: boolean;\n squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';\n squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';\n allowMergeCommit?: boolean;\n allowAutoMerge?: boolean;\n requireCodeOwnerReviews?: boolean;\n bypassPullRequestAllowances?: {\n users?: string[];\n teams?: string[];\n apps?: string[];\n };\n requiredApprovingReviewCount?: number;\n restrictions?: {\n users: string[];\n teams: string[];\n apps?: string[];\n };\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n repoVisibility?: 'private' | 'internal' | 'public';\n collaborators?: Array<\n | {\n user: string;\n access: string;\n }\n | {\n team: string;\n access: string;\n }\n | {\n /** @deprecated This field is deprecated in favor of team */\n username: string;\n access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';\n }\n >;\n hasProjects?: boolean;\n hasWiki?: boolean;\n hasIssues?: boolean;\n token?: string;\n topics?: string[];\n repoVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n oidcCustomization?: {\n useDefault: boolean;\n includeClaimKeys?: string[];\n };\n requireCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n customProperties?: { [key: string]: string };\n subscribe?: boolean;\n }>({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\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 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 },\n output: {\n type: 'object',\n properties: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\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 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(octokitOptions);\n\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 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\n ctx.output('remoteUrl', newRepo.clone_url);\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.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,EA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,IAAA;AAAA,QACA,KAAA;AAAA,QACA,cAAA;AAAA,QACA,WAAA;AAAA,QACA,QAAA;AAAA,QACA,mBAAA;AAAA,QACA,gBAAA;AAAA,QACA,gBAAA;AAAA,QACA,sBAAA;AAAA,QACA,wBAAA;AAAA,QACA,gBAAA;AAAA,QACA,cAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAA;AAAA,QACA,WAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAA;AAAA,QACA,OAAA;AAAA,QACA,iBAAA;AAAA,QACA,gBAAA;AAAA,QACA,SAAA;AAAA,QACA,GAAI,CAAA;AAAA,OACN;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,WAAa,EAAA,OAAA,CAAQ,SAAS,CAAA;AAAA;AAC3C,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 repoUrl: string;\n description?: string;\n homepage?: string;\n access?: string;\n deleteBranchOnMerge?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n allowRebaseMerge?: boolean;\n allowSquashMerge?: boolean;\n squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';\n squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';\n allowMergeCommit?: boolean;\n allowAutoMerge?: boolean;\n requireCodeOwnerReviews?: boolean;\n bypassPullRequestAllowances?: {\n users?: string[];\n teams?: string[];\n apps?: string[];\n };\n requiredApprovingReviewCount?: number;\n restrictions?: {\n users: string[];\n teams: string[];\n apps?: string[];\n };\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n repoVisibility?: 'private' | 'internal' | 'public';\n collaborators?: Array<\n | {\n user: string;\n access: string;\n }\n | {\n team: string;\n access: string;\n }\n | {\n /** @deprecated This field is deprecated in favor of team */\n username: string;\n access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';\n }\n >;\n hasProjects?: boolean;\n hasWiki?: boolean;\n hasIssues?: boolean;\n token?: string;\n topics?: string[];\n repoVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n oidcCustomization?: {\n useDefault: boolean;\n includeClaimKeys?: string[];\n };\n requireCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n customProperties?: { [key: string]: string };\n subscribe?: boolean;\n }>({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\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 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 },\n output: {\n type: 'object',\n properties: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\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 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(octokitOptions);\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 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.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":";;;;;;;;;;;AAq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S,IAAIC,eAAA,CAAQ,cAAc,CAAA;AAEzC,MAAM,MAAA,SAAA,GAAY,MAAM,GAAA,CAAI,UAAW,CAAA;AAAA,QACrC,GAAK,EAAA,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC5C,IAAI,YAAY;AACd,UAAA,MAAM,UAAU,MAAMC,kDAAA;AAAA,YACpB,MAAA;AAAA,YACA,IAAA;AAAA,YACA,KAAA;AAAA,YACA,cAAA;AAAA,YACA,WAAA;AAAA,YACA,QAAA;AAAA,YACA,mBAAA;AAAA,YACA,gBAAA;AAAA,YACA,gBAAA;AAAA,YACA,sBAAA;AAAA,YACA,wBAAA;AAAA,YACA,gBAAA;AAAA,YACA,cAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAA;AAAA,YACA,WAAA;AAAA,YACA,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;;;;"}
@@ -89,34 +89,40 @@ function createGithubRepoPushAction(options) {
89
89
  const targetRepo = await client.rest.repos.get({ owner, repo });
90
90
  const remoteUrl = targetRepo.data.clone_url;
91
91
  const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;
92
- const { commitHash } = await helpers.initRepoPushAndProtect(
93
- remoteUrl,
94
- octokitOptions.auth,
95
- ctx.workspacePath,
96
- ctx.input.sourcePath,
97
- defaultBranch,
98
- protectDefaultBranch,
99
- protectEnforceAdmins,
100
- owner,
101
- client,
102
- repo,
103
- requireCodeOwnerReviews,
104
- bypassPullRequestAllowances,
105
- requiredApprovingReviewCount,
106
- restrictions,
107
- requiredStatusCheckContexts,
108
- requireBranchesToBeUpToDate,
109
- requiredConversationResolution,
110
- requireLastPushApproval,
111
- config,
112
- ctx.logger,
113
- gitCommitMessage,
114
- gitAuthorName,
115
- gitAuthorEmail,
116
- dismissStaleReviews,
117
- requiredCommitSigning,
118
- requiredLinearHistory
119
- );
92
+ const commitHash = await ctx.checkpoint({
93
+ key: `init.repo.publish.${owner}.${client}.${repo}`,
94
+ fn: async () => {
95
+ const { commitHash: hash } = await helpers.initRepoPushAndProtect(
96
+ remoteUrl,
97
+ octokitOptions.auth,
98
+ ctx.workspacePath,
99
+ ctx.input.sourcePath,
100
+ defaultBranch,
101
+ protectDefaultBranch,
102
+ protectEnforceAdmins,
103
+ owner,
104
+ client,
105
+ repo,
106
+ requireCodeOwnerReviews,
107
+ bypassPullRequestAllowances,
108
+ requiredApprovingReviewCount,
109
+ restrictions,
110
+ requiredStatusCheckContexts,
111
+ requireBranchesToBeUpToDate,
112
+ requiredConversationResolution,
113
+ requireLastPushApproval,
114
+ config,
115
+ ctx.logger,
116
+ gitCommitMessage,
117
+ gitAuthorName,
118
+ gitAuthorEmail,
119
+ dismissStaleReviews,
120
+ requiredCommitSigning,
121
+ requiredLinearHistory
122
+ );
123
+ return hash;
124
+ }
125
+ });
120
126
  ctx.output("remoteUrl", remoteUrl);
121
127
  ctx.output("repoContentsUrl", repoContentsUrl);
122
128
  ctx.output("commitHash", commitHash);
@@ -1 +1 @@
1
- {"version":3,"file":"githubRepoPush.cjs.js","sources":["../../src/actions/githubRepoPush.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 { Config } from '@backstage/config';\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 { initRepoPushAndProtect } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoPush.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitHub.\n *\n * @public\n */\nexport function createGithubRepoPushAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, config, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n protectDefaultBranch?: boolean;\n protectEnforceAdmins?: boolean;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n requireCodeOwnerReviews?: boolean;\n dismissStaleReviews?: boolean;\n bypassPullRequestAllowances?:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined;\n requiredApprovingReviewCount?: number;\n restrictions?:\n | {\n users: string[];\n teams: string[];\n apps?: string[];\n }\n | undefined;\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n sourcePath?: string;\n token?: string;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n requireLastPushApproval?: boolean;\n }>({\n id: 'github:repo:push',\n description:\n 'Initializes a git repository of contents in workspace and publishes it to GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: inputProps.repoUrl,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\n sourcePath: inputProps.sourcePath,\n token: inputProps.token,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n defaultBranch = 'master',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount = 1,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n token: providedToken,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\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\n const client = new Octokit(octokitOptions);\n\n const targetRepo = await client.rest.repos.get({ owner, repo });\n\n const remoteUrl = targetRepo.data.clone_url;\n const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;\n\n const { commitHash } = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('commitHash', commitHash);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.sourcePath","inputProps.token","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AAuCO,SAAS,2BAA2B,OAIxC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAQ,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAE5D,EAAA,OAAOA,yCAkCJ,CAAA;AAAA,IACD,EAAI,EAAA,kBAAA;AAAA,IACJ,WACE,EAAA,mFAAA;AAAA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,QACA,MAAA;AAAA,QACA,IAAA;AAAA,QACA,uBAAA;AAAA,QACA,2BAAA;AAAA,QACA,4BAAA;AAAA,QACA,YAAA;AAAA,QACA,2BAAA;AAAA,QACA,2BAAA;AAAA,QACA,8BAAA;AAAA,QACA,uBAAA;AAAA,QACA,MAAA;AAAA,QACA,GAAI,CAAA,MAAA;AAAA,QACJ,gBAAA;AAAA,QACA,aAAA;AAAA,QACA,cAAA;AAAA,QACA,mBAAA;AAAA,QACA,qBAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,cAAc,UAAU,CAAA;AAAA;AACrC,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubRepoPush.cjs.js","sources":["../../src/actions/githubRepoPush.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 { Config } from '@backstage/config';\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 { initRepoPushAndProtect } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoPush.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitHub.\n *\n * @public\n */\nexport function createGithubRepoPushAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, config, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n protectDefaultBranch?: boolean;\n protectEnforceAdmins?: boolean;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n requireCodeOwnerReviews?: boolean;\n dismissStaleReviews?: boolean;\n bypassPullRequestAllowances?:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined;\n requiredApprovingReviewCount?: number;\n restrictions?:\n | {\n users: string[];\n teams: string[];\n apps?: string[];\n }\n | undefined;\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n sourcePath?: string;\n token?: string;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n requireLastPushApproval?: boolean;\n }>({\n id: 'github:repo:push',\n description:\n 'Initializes a git repository of contents in workspace and publishes it to GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: inputProps.repoUrl,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\n sourcePath: inputProps.sourcePath,\n token: inputProps.token,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n defaultBranch = 'master',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount = 1,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n token: providedToken,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\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\n const client = new Octokit(octokitOptions);\n\n const targetRepo = await client.rest.repos.get({ owner, repo });\n\n const remoteUrl = targetRepo.data.clone_url;\n const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;\n\n const commitHash = await ctx.checkpoint({\n key: `init.repo.publish.${owner}.${client}.${repo}`,\n fn: async () => {\n const { commitHash: hash } = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n return hash;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('commitHash', commitHash);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.sourcePath","inputProps.token","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AAuCO,SAAS,2BAA2B,OAIxC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAQ,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAE5D,EAAA,OAAOA,yCAkCJ,CAAA;AAAA,IACD,EAAI,EAAA,kBAAA;AAAA,IACJ,WACE,EAAA,mFAAA;AAAA,cACFC,gCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,SAASC,uBAAW;AAAA,UACpB,yBAAyBC,uCAAW;AAAA,UACpC,qBAAqBC,mCAAW;AAAA,UAChC,6BAA6BC,2CAAW;AAAA,UACxC,6BAA6BC,2CAAW;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A,2BAAA;AAAA,YACA,2BAAA;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,MAAA;AAAA,YACA,GAAI,CAAA,MAAA;AAAA,YACJ,gBAAA;AAAA,YACA,aAAA;AAAA,YACA,cAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACF;AACA,UAAO,OAAA,IAAA;AAAA;AACT,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,cAAc,UAAU,CAAA;AAAA;AACrC,GACD,CAAA;AACH;;;;"}
@@ -114,17 +114,22 @@ function createGithubWebhookAction(options) {
114
114
  }
115
115
  try {
116
116
  const insecure_ssl = insecureSsl ? "1" : "0";
117
- await client.rest.repos.createWebhook({
118
- owner,
119
- repo,
120
- config: {
121
- url: webhookUrl,
122
- content_type: contentType,
123
- secret: webhookSecret,
124
- insecure_ssl
125
- },
126
- events,
127
- active
117
+ await ctx.checkpoint({
118
+ key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,
119
+ fn: async () => {
120
+ await client.rest.repos.createWebhook({
121
+ owner,
122
+ repo,
123
+ config: {
124
+ url: webhookUrl,
125
+ content_type: contentType,
126
+ secret: webhookSecret,
127
+ insecure_ssl
128
+ },
129
+ events,
130
+ active
131
+ });
132
+ }
128
133
  });
129
134
  ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);
130
135
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.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 { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n type: 'array',\n default: ['push'],\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n default: true,\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n default: 'form',\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n default: false,\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\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 client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAIvC,EAAA;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AAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAO,EAAA;AAAA,SACR;AAAA,OACH;AAGA,MAAA,IAAI,IAAI,QAAU,EAAA;AAChB,QAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAkB,gBAAA,CAAA,CAAA;AAClC,QAAA;AAAA;AAGF,MAAI,IAAA;AACF,QAAM,MAAA,YAAA,GAAe,cAAc,GAAM,GAAA,GAAA;AACzC,QAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,aAAc,CAAA;AAAA,UACpC,KAAA;AAAA,UACA,IAAA;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,GAAK,EAAA,UAAA;AAAA,YACL,YAAc,EAAA,WAAA;AAAA,YACd,MAAQ,EAAA,aAAA;AAAA,YACR;AAAA,WACF;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAAwB,sBAAA,CAAA,CAAA;AAAA,eACvD,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,2BAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACzE;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.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 { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n type: 'array',\n default: ['push'],\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n default: true,\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n default: 'form',\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n default: false,\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\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 client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n\n await ctx.checkpoint({\n key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,\n fn: async () => {\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n },\n });\n\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parse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zE;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-github",
3
- "version": "0.6.1-next.2",
3
+ "version": "0.6.2-next.0",
4
4
  "description": "The github module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -43,13 +43,14 @@
43
43
  "test": "backstage-cli package test"
44
44
  },
45
45
  "dependencies": {
46
- "@backstage/backend-plugin-api": "1.2.1-next.1",
46
+ "@backstage/backend-plugin-api": "1.2.1",
47
47
  "@backstage/catalog-client": "1.9.1",
48
48
  "@backstage/catalog-model": "1.7.3",
49
49
  "@backstage/config": "1.3.2",
50
50
  "@backstage/errors": "1.2.7",
51
- "@backstage/integration": "1.16.2-next.0",
52
- "@backstage/plugin-scaffolder-node": "0.8.0-next.2",
51
+ "@backstage/integration": "1.16.2",
52
+ "@backstage/plugin-scaffolder-node": "0.8.1-next.0",
53
+ "@backstage/types": "1.2.1",
53
54
  "@octokit/webhooks": "^10.9.2",
54
55
  "libsodium-wrappers": "^0.7.11",
55
56
  "octokit": "^3.0.0",
@@ -57,9 +58,9 @@
57
58
  "yaml": "^2.0.0"
58
59
  },
59
60
  "devDependencies": {
60
- "@backstage/backend-test-utils": "1.3.1-next.2",
61
- "@backstage/cli": "0.31.0-next.1",
62
- "@backstage/plugin-scaffolder-node-test-utils": "0.2.0-next.2",
61
+ "@backstage/backend-test-utils": "1.3.2-next.0",
62
+ "@backstage/cli": "0.32.0-next.0",
63
+ "@backstage/plugin-scaffolder-node-test-utils": "0.2.1-next.0",
63
64
  "@types/libsodium-wrappers": "^0.7.10",
64
65
  "fs-extra": "^11.2.0",
65
66
  "jsonschema": "^1.2.6"