@backstage/plugin-scaffolder-backend-module-github 0.5.6-next.1 → 0.6.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 +67 -0
- package/dist/actions/githubActionsDispatch.cjs.js +2 -2
- package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
- package/dist/actions/githubAutolinks.cjs.js +5 -4
- package/dist/actions/githubAutolinks.cjs.js.map +1 -1
- package/dist/actions/githubDeployKey.cjs.js +4 -4
- package/dist/actions/githubDeployKey.cjs.js.map +1 -1
- package/dist/actions/githubEnvironment.cjs.js +6 -6
- package/dist/actions/githubEnvironment.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.cjs.js +2 -2
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.cjs.js +8 -3
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.cjs.js +18 -7
- package/dist/actions/githubPullRequest.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.examples.cjs.js +33 -14
- package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.cjs.js +10 -6
- package/dist/actions/githubWebhook.cjs.js.map +1 -1
- package/dist/actions/inputProperties.cjs.js +39 -21
- package/dist/actions/inputProperties.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +11 -11
|
@@ -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 }>({\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: `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 merge 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 },\n },\n output: {\n required: ['remoteUrl'],\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 } = 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 };\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 (!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","Input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;AAAA,QACL,gBAAgB,UAAU,CAAA,aAAA,EAAgB,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,OACjG;AAAA,aACO,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 { 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,CA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AAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA;AACF;AAEJ;;;;;"}
|
|
@@ -13,7 +13,7 @@ const examples = [
|
|
|
13
13
|
steps: [
|
|
14
14
|
{
|
|
15
15
|
action: "publish:github:pull-request",
|
|
16
|
-
name: "Create a pull
|
|
16
|
+
name: "Create a pull request",
|
|
17
17
|
input: {
|
|
18
18
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
19
19
|
branchName: "new-app",
|
|
@@ -30,7 +30,7 @@ const examples = [
|
|
|
30
30
|
steps: [
|
|
31
31
|
{
|
|
32
32
|
action: "publish:github:pull-request",
|
|
33
|
-
name: "Create a pull
|
|
33
|
+
name: "Create a pull request with target branch name",
|
|
34
34
|
input: {
|
|
35
35
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
36
36
|
branchName: "new-app",
|
|
@@ -48,7 +48,7 @@ const examples = [
|
|
|
48
48
|
steps: [
|
|
49
49
|
{
|
|
50
50
|
action: "publish:github:pull-request",
|
|
51
|
-
name: "Create a pull
|
|
51
|
+
name: "Create a pull request as draft",
|
|
52
52
|
input: {
|
|
53
53
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
54
54
|
branchName: "new-app",
|
|
@@ -66,7 +66,7 @@ const examples = [
|
|
|
66
66
|
steps: [
|
|
67
67
|
{
|
|
68
68
|
action: "publish:github:pull-request",
|
|
69
|
-
name: "Create a pull
|
|
69
|
+
name: "Create a pull request with target path",
|
|
70
70
|
input: {
|
|
71
71
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
72
72
|
branchName: "new-app",
|
|
@@ -84,7 +84,7 @@ const examples = [
|
|
|
84
84
|
steps: [
|
|
85
85
|
{
|
|
86
86
|
action: "publish:github:pull-request",
|
|
87
|
-
name: "Create a pull
|
|
87
|
+
name: "Create a pull request with source path",
|
|
88
88
|
input: {
|
|
89
89
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
90
90
|
branchName: "new-app",
|
|
@@ -102,7 +102,7 @@ const examples = [
|
|
|
102
102
|
steps: [
|
|
103
103
|
{
|
|
104
104
|
action: "publish:github:pull-request",
|
|
105
|
-
name: "Create a pull
|
|
105
|
+
name: "Create a pull request",
|
|
106
106
|
input: {
|
|
107
107
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
108
108
|
branchName: "new-app",
|
|
@@ -120,7 +120,7 @@ const examples = [
|
|
|
120
120
|
steps: [
|
|
121
121
|
{
|
|
122
122
|
action: "publish:github:pull-request",
|
|
123
|
-
name: "Create a pull
|
|
123
|
+
name: "Create a pull request with reviewers",
|
|
124
124
|
input: {
|
|
125
125
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
126
126
|
branchName: "new-app",
|
|
@@ -138,7 +138,7 @@ const examples = [
|
|
|
138
138
|
steps: [
|
|
139
139
|
{
|
|
140
140
|
action: "publish:github:pull-request",
|
|
141
|
-
name: "Create a pull
|
|
141
|
+
name: "Create a pull request with team reviewers",
|
|
142
142
|
input: {
|
|
143
143
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
144
144
|
branchName: "new-app",
|
|
@@ -156,7 +156,7 @@ const examples = [
|
|
|
156
156
|
steps: [
|
|
157
157
|
{
|
|
158
158
|
action: "publish:github:pull-request",
|
|
159
|
-
name: "Create a pull
|
|
159
|
+
name: "Create a pull request",
|
|
160
160
|
input: {
|
|
161
161
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
162
162
|
branchName: "new-app",
|
|
@@ -174,7 +174,7 @@ const examples = [
|
|
|
174
174
|
steps: [
|
|
175
175
|
{
|
|
176
176
|
action: "publish:github:pull-request",
|
|
177
|
-
name: "Create a pull
|
|
177
|
+
name: "Create a pull request",
|
|
178
178
|
input: {
|
|
179
179
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
180
180
|
branchName: "new-app",
|
|
@@ -193,7 +193,7 @@ const examples = [
|
|
|
193
193
|
steps: [
|
|
194
194
|
{
|
|
195
195
|
action: "publish:github:pull-request",
|
|
196
|
-
name: "Create a pull
|
|
196
|
+
name: "Create a pull request",
|
|
197
197
|
input: {
|
|
198
198
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
199
199
|
branchName: "new-app",
|
|
@@ -213,7 +213,7 @@ const examples = [
|
|
|
213
213
|
steps: [
|
|
214
214
|
{
|
|
215
215
|
action: "publish:github:pull-request",
|
|
216
|
-
name: "Create a pull
|
|
216
|
+
name: "Create a pull request",
|
|
217
217
|
input: {
|
|
218
218
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
219
219
|
branchName: "new-app",
|
|
@@ -227,13 +227,31 @@ const examples = [
|
|
|
227
227
|
]
|
|
228
228
|
})
|
|
229
229
|
},
|
|
230
|
+
{
|
|
231
|
+
description: "Do not create empty pull request",
|
|
232
|
+
example: yaml__default.default.stringify({
|
|
233
|
+
steps: [
|
|
234
|
+
{
|
|
235
|
+
action: "publish:github:pull-request",
|
|
236
|
+
name: "Create a pull request",
|
|
237
|
+
input: {
|
|
238
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
239
|
+
branchName: "new-app",
|
|
240
|
+
title: "Create my new app",
|
|
241
|
+
description: "This PR is really good",
|
|
242
|
+
createWhenEmpty: false
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
})
|
|
247
|
+
},
|
|
230
248
|
{
|
|
231
249
|
description: "Create a pull request with all parameters",
|
|
232
250
|
example: yaml__default.default.stringify({
|
|
233
251
|
steps: [
|
|
234
252
|
{
|
|
235
253
|
action: "publish:github:pull-request",
|
|
236
|
-
name: "Create a pull
|
|
254
|
+
name: "Create a pull request",
|
|
237
255
|
input: {
|
|
238
256
|
repoUrl: "github.com?repo=repo&owner=owner",
|
|
239
257
|
branchName: "new-app",
|
|
@@ -248,7 +266,8 @@ const examples = [
|
|
|
248
266
|
teamReviewers: ["team-foo"],
|
|
249
267
|
commitMessage: "Commit for foo changes",
|
|
250
268
|
gitAuthorName: "Foo Bar",
|
|
251
|
-
gitAuthorEmail: "foo@bar.example"
|
|
269
|
+
gitAuthorEmail: "foo@bar.example",
|
|
270
|
+
createWhenEmpty: true
|
|
252
271
|
}
|
|
253
272
|
}
|
|
254
273
|
]
|
|
@@ -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 reuqest',\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 reuqest 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 reuqest 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 reuqest 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 reuqest 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 reuqest',\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 reuqest 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 reuqest 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 reuqest',\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 reuqest',\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 reuqest',\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 reuqest',\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: '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 reuqest',\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 },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uBAAA;A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YACb,gBAAkB,EAAA,MAAA;AAAA,YAClB,KAAO,EAAA,IAAA;AAAA,YACP,UAAY,EAAA,YAAA;AAAA,YACZ,UAAY,EAAA,QAAA;AAAA,YACZ,KAAO,EAAA,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;AAAA;AAClB;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"],"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,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,gBAAkB,EAAA;AAAA;AACpB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,gCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE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
|
|
22
22
|
properties: {
|
|
23
23
|
repoUrl: {
|
|
24
24
|
title: "Repository Location",
|
|
25
|
-
description:
|
|
25
|
+
description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
|
|
26
26
|
type: "string"
|
|
27
27
|
},
|
|
28
28
|
webhookUrl: {
|
|
@@ -37,8 +37,9 @@ function createGithubWebhookAction(options) {
|
|
|
37
37
|
},
|
|
38
38
|
events: {
|
|
39
39
|
title: "Triggering Events",
|
|
40
|
-
description: "Determines what events the hook is triggered for. Default: push",
|
|
40
|
+
description: "Determines what events the hook is triggered for. Default: `[push]`",
|
|
41
41
|
type: "array",
|
|
42
|
+
default: ["push"],
|
|
42
43
|
oneOf: [
|
|
43
44
|
{
|
|
44
45
|
items: {
|
|
@@ -57,23 +58,26 @@ function createGithubWebhookAction(options) {
|
|
|
57
58
|
active: {
|
|
58
59
|
title: "Active",
|
|
59
60
|
type: "boolean",
|
|
60
|
-
|
|
61
|
+
default: true,
|
|
62
|
+
description: "Determines if notifications are sent when the webhook is triggered. Default: `true`"
|
|
61
63
|
},
|
|
62
64
|
contentType: {
|
|
63
65
|
title: "Content Type",
|
|
64
66
|
type: "string",
|
|
65
67
|
enum: ["form", "json"],
|
|
66
|
-
|
|
68
|
+
default: "form",
|
|
69
|
+
description: "The media type used to serialize the payloads. The default is `form`"
|
|
67
70
|
},
|
|
68
71
|
insecureSsl: {
|
|
69
72
|
title: "Insecure SSL",
|
|
70
73
|
type: "boolean",
|
|
71
|
-
|
|
74
|
+
default: false,
|
|
75
|
+
description: "Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`"
|
|
72
76
|
},
|
|
73
77
|
token: {
|
|
74
78
|
title: "Authentication Token",
|
|
75
79
|
type: "string",
|
|
76
|
-
description: "The GITHUB_TOKEN to use for authorization to GitHub"
|
|
80
|
+
description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
}
|
|
@@ -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
|
|
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;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAsB,EAAA,yBAAA,EAC1C,GAAA,OAAA;AAEF,EAAM,MAAA,UAAA,GAAaA,2BAAkB,MAAO,CAAA,CAAA,KAAA,KAAS,CAAC,KAAM,CAAA,QAAA,CAAS,GAAG,CAAC,CAAA;AAEzE,EAAA,OAAOC,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,gBAAA;AAAA,IACJ,WAAa,EAAA,6CAAA;AAAA,cACbC,+BAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,YAAY,CAAA;AAAA,QAClC,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,aAAA;AAAA,YACP,WAAa,EAAA,iDAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,aAAe,EAAA;AAAA,YACb,KAAO,EAAA,gBAAA;AAAA,YACP,WACE,EAAA,iFAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,mBAAA;AAAA,YACP,WACE,EAAA,qEAAA;AAAA,YACF,IAAM,EAAA,OAAA;AAAA,YACN,OAAA,EAAS,CAAC,MAAM,CAAA;AAAA,YAChB,KAAO,EAAA;AAAA,cACL;AAAA,gBACE,KAAO,EAAA;AAAA,kBACL,IAAM,EAAA,QAAA;AAAA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repository Location",
|
|
5
|
-
description:
|
|
5
|
+
description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
|
|
6
6
|
type: "string"
|
|
7
7
|
};
|
|
8
8
|
const description = {
|
|
@@ -15,7 +15,7 @@ const homepage = {
|
|
|
15
15
|
};
|
|
16
16
|
const access = {
|
|
17
17
|
title: "Repository Access",
|
|
18
|
-
description:
|
|
18
|
+
description: "Sets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`",
|
|
19
19
|
type: "string"
|
|
20
20
|
};
|
|
21
21
|
const requireCodeOwnerReviews = {
|
|
@@ -38,8 +38,9 @@ const requiredStatusCheckContexts = {
|
|
|
38
38
|
};
|
|
39
39
|
const requireBranchesToBeUpToDate = {
|
|
40
40
|
title: "Require Branches To Be Up To Date?",
|
|
41
|
-
description:
|
|
42
|
-
type: "boolean"
|
|
41
|
+
description: "Require branches to be up to date before merging. The default value is `true`",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
default: true
|
|
43
44
|
};
|
|
44
45
|
const requiredConversationResolution = {
|
|
45
46
|
title: "Required Conversation Resolution",
|
|
@@ -49,7 +50,8 @@ const requiredConversationResolution = {
|
|
|
49
50
|
const requireLastPushApproval = {
|
|
50
51
|
title: "Require last push approval",
|
|
51
52
|
type: "boolean",
|
|
52
|
-
|
|
53
|
+
default: false,
|
|
54
|
+
description: "Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`"
|
|
53
55
|
};
|
|
54
56
|
const repoVisibility = {
|
|
55
57
|
title: "Repository Visibility",
|
|
@@ -59,12 +61,14 @@ const repoVisibility = {
|
|
|
59
61
|
const deleteBranchOnMerge = {
|
|
60
62
|
title: "Delete Branch On Merge",
|
|
61
63
|
type: "boolean",
|
|
62
|
-
|
|
64
|
+
default: false,
|
|
65
|
+
description: "Delete the branch after merging the PR. The default value is `false`"
|
|
63
66
|
};
|
|
64
67
|
const gitAuthorName = {
|
|
65
68
|
title: "Default Author Name",
|
|
66
69
|
type: "string",
|
|
67
|
-
|
|
70
|
+
default: "Scaffolder",
|
|
71
|
+
description: "Sets the default author name for the commit. The default value is `Scaffolder`"
|
|
68
72
|
};
|
|
69
73
|
const gitAuthorEmail = {
|
|
70
74
|
title: "Default Author Email",
|
|
@@ -74,32 +78,40 @@ const gitAuthorEmail = {
|
|
|
74
78
|
const allowMergeCommit = {
|
|
75
79
|
title: "Allow Merge Commits",
|
|
76
80
|
type: "boolean",
|
|
77
|
-
|
|
81
|
+
default: true,
|
|
82
|
+
description: "Allow merge commits. The default value is `true`"
|
|
78
83
|
};
|
|
79
84
|
const allowSquashMerge = {
|
|
80
85
|
title: "Allow Squash Merges",
|
|
81
86
|
type: "boolean",
|
|
82
|
-
|
|
87
|
+
default: true,
|
|
88
|
+
description: "Allow squash merges. The default value is `true`"
|
|
83
89
|
};
|
|
84
90
|
const squashMergeCommitTitle = {
|
|
85
91
|
title: "Default squash merge commit title",
|
|
86
92
|
enum: ["PR_TITLE", "COMMIT_OR_PR_TITLE"],
|
|
87
|
-
|
|
93
|
+
type: "string",
|
|
94
|
+
default: "COMMIT_OR_PR_TITLE",
|
|
95
|
+
description: "Sets the default value for a squash merge commit title. The default value is `COMMIT_OR_PR_TITLE`"
|
|
88
96
|
};
|
|
89
97
|
const squashMergeCommitMessage = {
|
|
90
98
|
title: "Default squash merge commit message",
|
|
91
99
|
enum: ["PR_BODY", "COMMIT_MESSAGES", "BLANK"],
|
|
92
|
-
|
|
100
|
+
type: "string",
|
|
101
|
+
default: "COMMIT_MESSAGES",
|
|
102
|
+
description: "Sets the default value for a squash merge commit message. The default value is `COMMIT_MESSAGES`"
|
|
93
103
|
};
|
|
94
104
|
const allowRebaseMerge = {
|
|
95
105
|
title: "Allow Rebase Merges",
|
|
96
106
|
type: "boolean",
|
|
97
|
-
|
|
107
|
+
default: true,
|
|
108
|
+
description: "Allow rebase merges. The default value is `true`"
|
|
98
109
|
};
|
|
99
110
|
const allowAutoMerge = {
|
|
100
111
|
title: "Allow Auto Merges",
|
|
101
112
|
type: "boolean",
|
|
102
|
-
|
|
113
|
+
default: false,
|
|
114
|
+
description: "Allow individual PRs to merge automatically when all merge requirements are met. The default value is `false`"
|
|
103
115
|
};
|
|
104
116
|
const collaborators = {
|
|
105
117
|
title: "Collaborators",
|
|
@@ -129,17 +141,19 @@ const collaborators = {
|
|
|
129
141
|
const hasProjects = {
|
|
130
142
|
title: "Enable projects",
|
|
131
143
|
type: "boolean",
|
|
132
|
-
description:
|
|
144
|
+
description: "Enable projects for the repository. The default value is `true` unless the organization has disabled repository projects"
|
|
133
145
|
};
|
|
134
146
|
const hasWiki = {
|
|
135
147
|
title: "Enable the wiki",
|
|
136
148
|
type: "boolean",
|
|
137
|
-
|
|
149
|
+
default: true,
|
|
150
|
+
description: "Enable the wiki for the repository. The default value is `true`"
|
|
138
151
|
};
|
|
139
152
|
const hasIssues = {
|
|
140
153
|
title: "Enable issues",
|
|
141
154
|
type: "boolean",
|
|
142
|
-
|
|
155
|
+
default: true,
|
|
156
|
+
description: "Enable issues for the repository. The default value is `true`"
|
|
143
157
|
};
|
|
144
158
|
const token = {
|
|
145
159
|
title: "Authentication Token",
|
|
@@ -156,17 +170,20 @@ const topics = {
|
|
|
156
170
|
const defaultBranch = {
|
|
157
171
|
title: "Default Branch",
|
|
158
172
|
type: "string",
|
|
159
|
-
|
|
173
|
+
default: "master",
|
|
174
|
+
description: "Sets the default branch on the repository. The default value is `master`"
|
|
160
175
|
};
|
|
161
176
|
const protectDefaultBranch = {
|
|
162
177
|
title: "Protect Default Branch",
|
|
163
178
|
type: "boolean",
|
|
164
|
-
|
|
179
|
+
default: true,
|
|
180
|
+
description: "Protect the default branch after creating the repository. The default value is `true`"
|
|
165
181
|
};
|
|
166
182
|
const protectEnforceAdmins = {
|
|
167
183
|
title: "Enforce Admins On Protected Branches",
|
|
168
184
|
type: "boolean",
|
|
169
|
-
|
|
185
|
+
default: true,
|
|
186
|
+
description: "Enforce admins to adhere to default branch protection. The default value is `true`"
|
|
170
187
|
};
|
|
171
188
|
const bypassPullRequestAllowances = {
|
|
172
189
|
title: "Bypass pull request requirements",
|
|
@@ -197,7 +214,8 @@ const bypassPullRequestAllowances = {
|
|
|
197
214
|
const gitCommitMessage = {
|
|
198
215
|
title: "Git Commit Message",
|
|
199
216
|
type: "string",
|
|
200
|
-
|
|
217
|
+
default: "initial commit",
|
|
218
|
+
description: "Sets the commit message on the repository. The default value is `initial commit`"
|
|
201
219
|
};
|
|
202
220
|
const sourcePath = {
|
|
203
221
|
title: "Source Path",
|
|
@@ -207,7 +225,7 @@ const sourcePath = {
|
|
|
207
225
|
const requiredApprovingReviewCount = {
|
|
208
226
|
title: "Required approving review count",
|
|
209
227
|
type: "number",
|
|
210
|
-
description:
|
|
228
|
+
description: "Specify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`."
|
|
211
229
|
};
|
|
212
230
|
const restrictions = {
|
|
213
231
|
title: "Restrict who can push to the protected branch",
|