@backstage/plugin-scaffolder-backend-module-github 0.7.2-next.1 → 0.8.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/dist/actions/github.cjs.js +45 -52
  3. package/dist/actions/github.cjs.js.map +1 -1
  4. package/dist/actions/githubActionsDispatch.cjs.js +15 -29
  5. package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
  6. package/dist/actions/githubAutolinks.cjs.js +15 -30
  7. package/dist/actions/githubAutolinks.cjs.js.map +1 -1
  8. package/dist/actions/githubBranchProtection.cjs.js +15 -23
  9. package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
  10. package/dist/actions/githubDeployKey.cjs.js +21 -41
  11. package/dist/actions/githubDeployKey.cjs.js.map +1 -1
  12. package/dist/actions/githubEnvironment.cjs.js +47 -89
  13. package/dist/actions/githubEnvironment.cjs.js.map +1 -1
  14. package/dist/actions/githubIssuesLabel.cjs.js +12 -27
  15. package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
  16. package/dist/actions/githubPagesEnable.cjs.js +15 -34
  17. package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
  18. package/dist/actions/githubPullRequest.cjs.js +66 -126
  19. package/dist/actions/githubPullRequest.cjs.js.map +1 -1
  20. package/dist/actions/githubRepoCreate.cjs.js +35 -42
  21. package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
  22. package/dist/actions/githubRepoPush.cjs.js +23 -30
  23. package/dist/actions/githubRepoPush.cjs.js.map +1 -1
  24. package/dist/actions/githubWebhook.cjs.js +29 -63
  25. package/dist/actions/githubWebhook.cjs.js.map +1 -1
  26. package/dist/actions/inputProperties.cjs.js +145 -281
  27. package/dist/actions/inputProperties.cjs.js.map +1 -1
  28. package/dist/actions/outputProperties.cjs.js +9 -12
  29. package/dist/actions/outputProperties.cjs.js.map +1 -1
  30. package/dist/index.d.ts +210 -211
  31. package/dist/module.cjs.js +4 -9
  32. package/dist/module.cjs.js.map +1 -1
  33. package/package.json +14 -13
@@ -50,134 +50,74 @@ const createPublishGithubPullRequestAction = (options) => {
50
50
  supportsDryRun: true,
51
51
  schema: {
52
52
  input: {
53
- required: ["repoUrl", "title", "description", "branchName"],
54
- type: "object",
55
- properties: {
56
- repoUrl: {
57
- title: "Repository Location",
58
- description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username",
59
- type: "string"
60
- },
61
- branchName: {
62
- type: "string",
63
- title: "Branch Name",
64
- description: "The name for the branch"
65
- },
66
- targetBranchName: {
67
- type: "string",
68
- title: "Target Branch Name",
69
- description: "The target branch name of the pull request"
70
- },
71
- title: {
72
- type: "string",
73
- title: "Pull Request Name",
74
- description: "The name for the pull request"
75
- },
76
- description: {
77
- type: "string",
78
- title: "Pull Request Description",
79
- description: "The description of the pull request"
80
- },
81
- draft: {
82
- type: "boolean",
83
- title: "Create as Draft",
84
- description: "Create a draft pull request"
85
- },
86
- sourcePath: {
87
- type: "string",
88
- title: "Working Subdirectory",
89
- description: "Subdirectory of working directory to copy changes from"
90
- },
91
- targetPath: {
92
- type: "string",
93
- title: "Repository Subdirectory",
94
- description: "Subdirectory of repository to apply changes to"
95
- },
96
- token: {
97
- title: "Authentication Token",
98
- type: "string",
99
- description: "The token to use for authorization to GitHub"
100
- },
101
- reviewers: {
102
- title: "Pull Request Reviewers",
103
- type: "array",
104
- items: {
105
- type: "string"
106
- },
107
- description: "The users that will be added as reviewers to the pull request"
108
- },
109
- assignees: {
110
- title: "Pull Request Assignees",
111
- type: "array",
112
- items: {
113
- type: "string"
114
- },
115
- description: "The users that will be added as assignees to the pull request"
116
- },
117
- teamReviewers: {
118
- title: "Pull Request Team Reviewers",
119
- type: "array",
120
- items: {
121
- type: "string"
122
- },
123
- description: "The teams that will be added as reviewers to the pull request"
124
- },
125
- commitMessage: {
126
- type: "string",
127
- title: "Commit Message",
128
- description: "The commit message for the pull request commit"
129
- },
130
- update: {
131
- type: "boolean",
132
- title: "Update",
133
- description: "Update pull request if already exists"
134
- },
135
- forceFork: {
136
- type: "boolean",
137
- title: "Force Fork",
138
- description: "Create pull request from a fork"
139
- },
140
- gitAuthorName: {
141
- type: "string",
142
- title: "Default Author Name",
143
- description: "Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`"
144
- },
145
- gitAuthorEmail: {
146
- type: "string",
147
- title: "Default Author Email",
148
- description: "Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`"
149
- },
150
- forceEmptyGitAuthor: {
151
- type: "boolean",
152
- title: "Force Empty Git Author",
153
- description: "Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github"
154
- },
155
- createWhenEmpty: {
156
- type: "boolean",
157
- title: "Create When Empty",
158
- description: "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."
159
- }
160
- }
53
+ repoUrl: (z) => z.string({
54
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username"
55
+ }),
56
+ branchName: (z) => z.string({
57
+ description: "The name for the branch"
58
+ }),
59
+ targetBranchName: (z) => z.string({
60
+ description: "The target branch name of the pull request"
61
+ }).optional(),
62
+ title: (z) => z.string({
63
+ description: "The name for the pull request"
64
+ }),
65
+ description: (z) => z.string({
66
+ description: "The description of the pull request"
67
+ }),
68
+ draft: (z) => z.boolean({
69
+ description: "Create a draft pull request"
70
+ }).optional(),
71
+ sourcePath: (z) => z.string({
72
+ description: "Subdirectory of working directory to copy changes from"
73
+ }).optional(),
74
+ targetPath: (z) => z.string({
75
+ description: "Subdirectory of repository to apply changes to"
76
+ }).optional(),
77
+ token: (z) => z.string({
78
+ description: "The token to use for authorization to GitHub"
79
+ }).optional(),
80
+ reviewers: (z) => z.array(z.string(), {
81
+ description: "The users that will be added as reviewers to the pull request"
82
+ }).optional(),
83
+ assignees: (z) => z.array(z.string(), {
84
+ description: "The users that will be added as assignees to the pull request"
85
+ }).optional(),
86
+ teamReviewers: (z) => z.array(z.string(), {
87
+ description: "The teams that will be added as reviewers to the pull request"
88
+ }).optional(),
89
+ commitMessage: (z) => z.string({
90
+ description: "The commit message for the pull request commit"
91
+ }).optional(),
92
+ update: (z) => z.boolean({
93
+ description: "Update pull request if already exists"
94
+ }).optional(),
95
+ forceFork: (z) => z.boolean({
96
+ description: "Create pull request from a fork"
97
+ }).optional(),
98
+ gitAuthorName: (z) => z.string({
99
+ description: "Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`"
100
+ }).optional(),
101
+ gitAuthorEmail: (z) => z.string({
102
+ description: "Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`"
103
+ }).optional(),
104
+ forceEmptyGitAuthor: (z) => z.boolean({
105
+ description: "Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github"
106
+ }).optional(),
107
+ createWhenEmpty: (z) => z.boolean({
108
+ description: "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."
109
+ }).optional()
161
110
  },
162
111
  output: {
163
- required: [],
164
- type: "object",
165
- properties: {
166
- targetBranchName: {
167
- title: "Target branch name of the merge request",
168
- type: "string"
169
- },
170
- remoteUrl: {
171
- type: "string",
172
- title: "Pull Request URL",
173
- description: "Link to the pull request in Github"
174
- },
175
- pullRequestNumber: {
176
- type: "number",
177
- title: "Pull Request Number",
178
- description: "The pull request number"
179
- }
180
- }
112
+ targetBranchName: (z) => z.string({
113
+ description: "Target branch name of the merge request"
114
+ }),
115
+ remoteUrl: (z) => z.string({
116
+ description: "Link to the pull request in Github"
117
+ }),
118
+ pullRequestNumber: (z) => z.number({
119
+ description: "The pull request number"
120
+ })
181
121
  }
182
122
  },
183
123
  async handler(ctx) {
@@ -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';\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 assignees?: 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 assignees: {\n title: 'Pull Request Assignees',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as assignees 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 assignees,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n const pullRequest = { owner, repo, number: pullRequestNumber };\n if (reviewers || teamReviewers) {\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n if (assignees) {\n if (assignees.length > 10) {\n ctx.logger.warn(\n 'Assignees list is too long, only the first 10 will be used.',\n );\n }\n await addAssigneesToPullRequest(\n pullRequest,\n assignees,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function addAssigneesToPullRequest(\n pr: GithubPullRequest,\n assignees: string[],\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.issues.addAssignees({\n owner: pr.owner,\n repo: pr.repo,\n issue_number: pr.number,\n assignees,\n });\n\n const addedAssignees = result.data.assignees?.join(', ') ?? '';\n\n logger.info(\n `Added assignees [${addedAssignees}] to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding assignees to Pull request ${pr.number}`,\n e,\n );\n }\n }\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"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;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ;AAAA,GACnC,CAAA;AACH;AAsDW,MAAA,oCAAA,GAAuC,CAClD,OACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,YAAA;AAAA,IACA,yBAAA;AAAA,IACA,aAAgB,GAAA,oBAAA;AAAA,IAChB;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,OAAOC,yCAoBJ,CAAA;AAAA,IACD,EAAI,EAAA,6BAAA;AAAA,cACJC,mCAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAU,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,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,WACjG;AAAA;AACF,OACD,CAAA;AAAA,aACM,CAAG,EAAA;AACV,MAAO,MAAA,CAAA,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA;AACF;AAEJ;;;;;"}
1
+ {"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport { 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 id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n branchName: z =>\n z.string({\n description: 'The name for the branch',\n }),\n targetBranchName: z =>\n z\n .string({\n description: 'The target branch name of the pull request',\n })\n .optional(),\n title: z =>\n z.string({\n description: 'The name for the pull request',\n }),\n description: z =>\n z.string({\n description: 'The description of the pull request',\n }),\n draft: z =>\n z\n .boolean({\n description: 'Create a draft pull request',\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as reviewers to the pull request',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as assignees to the pull request',\n })\n .optional(),\n teamReviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The teams that will be added as reviewers to the pull request',\n })\n .optional(),\n commitMessage: z =>\n z\n .string({\n description: 'The commit message for the pull request commit',\n })\n .optional(),\n update: z =>\n z\n .boolean({\n description: 'Update pull request if already exists',\n })\n .optional(),\n forceFork: z =>\n z\n .boolean({\n description: 'Create pull request from a fork',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n })\n .optional(),\n forceEmptyGitAuthor: z =>\n z\n .boolean({\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n })\n .optional(),\n createWhenEmpty: z =>\n z\n .boolean({\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n })\n .optional(),\n },\n output: {\n targetBranchName: z =>\n z.string({\n description: 'Target branch name of the merge request',\n }),\n remoteUrl: z =>\n z.string({\n description: 'Link to the pull request in Github',\n }),\n pullRequestNumber: z =>\n z.number({\n description: 'The pull request number',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n assignees,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n const pullRequest = { owner, repo, number: pullRequestNumber };\n if (reviewers || teamReviewers) {\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n if (assignees) {\n if (assignees.length > 10) {\n ctx.logger.warn(\n 'Assignees list is too long, only the first 10 will be used.',\n );\n }\n await addAssigneesToPullRequest(\n pullRequest,\n assignees,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function addAssigneesToPullRequest(\n pr: GithubPullRequest,\n assignees: string[],\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.issues.addAssignees({\n owner: pr.owner,\n repo: pr.repo,\n issue_number: pr.number,\n assignees,\n });\n\n const addedAssignees = result.data.assignees?.join(', ') ?? '';\n\n logger.info(\n `Added assignees [${addedAssignees}] to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding assignees to Pull request ${pr.number}`,\n e,\n );\n }\n }\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"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;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ;AAAA,GACnC,CAAA;AACH;AAsDW,MAAA,oCAAA,GAAuC,CAClD,OACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,YAAA;AAAA,IACA,yBAAA;AAAA,IACA,aAAgB,GAAA,oBAAA;AAAA,IAChB;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,OAAOC,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,6BAAA;AAAA,cACJC,mCAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,CACP,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CACV,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WAAa,EAAA;AAAA,SACd,CAAA;AAAA,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AAM,CAAA,CAAA;AAAA,QAC1D,IAAI,YAAY;AACd,UAAA,MAAM,MAAS,GAAA,MAAM,MAAO,CAAA,IAAA,CAAK,MAAM,gBAAiB,CAAA;AAAA,YACtD,OAAO,EAAG,CAAA,KAAA;AAAA,YACV,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;;;;;"}
@@ -17,50 +17,43 @@ function createGithubRepoCreateAction(options) {
17
17
  examples: githubRepoCreate_examples.examples,
18
18
  schema: {
19
19
  input: {
20
- type: "object",
21
- required: ["repoUrl"],
22
- properties: {
23
- repoUrl: inputProperties.repoUrl,
24
- description: inputProperties.description,
25
- homepage: inputProperties.homepage,
26
- access: inputProperties.access,
27
- requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
28
- bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
29
- requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
30
- restrictions: inputProperties.restrictions,
31
- requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
32
- requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
33
- requiredConversationResolution: inputProperties.requiredConversationResolution,
34
- repoVisibility: inputProperties.repoVisibility,
35
- deleteBranchOnMerge: inputProperties.deleteBranchOnMerge,
36
- allowMergeCommit: inputProperties.allowMergeCommit,
37
- allowSquashMerge: inputProperties.allowSquashMerge,
38
- squashMergeCommitTitle: inputProperties.squashMergeCommitTitle,
39
- squashMergeCommitMessage: inputProperties.squashMergeCommitMessage,
40
- allowRebaseMerge: inputProperties.allowRebaseMerge,
41
- allowAutoMerge: inputProperties.allowAutoMerge,
42
- allowUpdateBranch: inputProperties.allowUpdateBranch,
43
- collaborators: inputProperties.collaborators,
44
- hasProjects: inputProperties.hasProjects,
45
- hasWiki: inputProperties.hasWiki,
46
- hasIssues: inputProperties.hasIssues,
47
- token: inputProperties.token,
48
- topics: inputProperties.topics,
49
- repoVariables: inputProperties.repoVariables,
50
- secrets: inputProperties.secrets,
51
- oidcCustomization: inputProperties.oidcCustomization,
52
- requiredCommitSigning: inputProperties.requiredCommitSigning,
53
- requiredLinearHistory: inputProperties.requiredLinearHistory,
54
- customProperties: inputProperties.customProperties,
55
- subscribe: inputProperties.subscribe
56
- }
20
+ repoUrl: inputProperties.repoUrl,
21
+ description: inputProperties.description,
22
+ homepage: inputProperties.homepage,
23
+ access: inputProperties.access,
24
+ requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
25
+ bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
26
+ requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
27
+ restrictions: inputProperties.restrictions,
28
+ requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
29
+ requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
30
+ requiredConversationResolution: inputProperties.requiredConversationResolution,
31
+ repoVisibility: inputProperties.repoVisibility,
32
+ deleteBranchOnMerge: inputProperties.deleteBranchOnMerge,
33
+ allowMergeCommit: inputProperties.allowMergeCommit,
34
+ allowSquashMerge: inputProperties.allowSquashMerge,
35
+ squashMergeCommitTitle: inputProperties.squashMergeCommitTitle,
36
+ squashMergeCommitMessage: inputProperties.squashMergeCommitMessage,
37
+ allowRebaseMerge: inputProperties.allowRebaseMerge,
38
+ allowAutoMerge: inputProperties.allowAutoMerge,
39
+ allowUpdateBranch: inputProperties.allowUpdateBranch,
40
+ collaborators: inputProperties.collaborators,
41
+ hasProjects: inputProperties.hasProjects,
42
+ hasWiki: inputProperties.hasWiki,
43
+ hasIssues: inputProperties.hasIssues,
44
+ token: inputProperties.token,
45
+ topics: inputProperties.topics,
46
+ repoVariables: inputProperties.repoVariables,
47
+ secrets: inputProperties.secrets,
48
+ oidcCustomization: inputProperties.oidcCustomization,
49
+ requiredCommitSigning: inputProperties.requiredCommitSigning,
50
+ requiredLinearHistory: inputProperties.requiredLinearHistory,
51
+ customProperties: inputProperties.customProperties,
52
+ subscribe: inputProperties.subscribe
57
53
  },
58
54
  output: {
59
- type: "object",
60
- properties: {
61
- remoteUrl: outputProperties.remoteUrl,
62
- repoContentsUrl: outputProperties.repoContentsUrl
63
- }
55
+ remoteUrl: outputProperties.remoteUrl,
56
+ repoContentsUrl: outputProperties.repoContentsUrl
64
57
  }
65
58
  },
66
59
  async handler(ctx) {
@@ -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 allowUpdateBranch?: 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 allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n },\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 allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n return newRepo.clone_url;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.requireCodeOwnerReviews","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.repoVisibility","inputProps.deleteBranchOnMerge","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings":";;;;;;;;;;;AAqCO,SAAS,6BAA6B,OAG1C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCA6DJ,CAAA;AAAA,IACD,EAAI,EAAA,oBAAA;AAAA,IACJ,WAAa,EAAA,8BAAA;AAAA,cACbC,kCAAA;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,aAAaC,2BAAW;AAAA,UACxB,UAAUC,wBAAW;AAAA,UACrB,QAAQC,sBAAW;AAAA,UACnB,yBAAyBC,uCAAW;AAAA,UACpC,6BAA6BC,2CAAW;AAAA,UACxC,8BAA8BC,4CAAW;AAAA,UACzC,cAAcC,4BAAW;AAAA,UACzB,6BAA6BC,2CAAW;AAAA,UACxC,6BAA6BC,2CAAW;AAAA,UACxC,gCACEC,8CAAW;AAAA,UACb,gBAAgBC,8BAAW;AAAA,UAC3B,qBAAqBC,mCAAW;AAAA,UAChC,kBAAkBC,gCAAW;AAAA,UAC7B,kBAAkBC,gCAAW;AAAA,UAC7B,wBAAwBC,sC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AA;AAAA,YACA,GAAI,CAAA;AAAA,WACN;AACA,UAAA,OAAO,OAAQ,CAAA,SAAA;AAAA;AACjB,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AAAA;AACnC,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubRepoCreate.cjs.js","sources":["../../src/actions/githubRepoCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { createGithubRepoWithCollaboratorsAndTopics } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoCreate.examples';\n\n/**\n * Creates a new action that initializes a git repository\n *\n * @public\n */\nexport function createGithubRepoCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n repoVisibility: inputProps.repoVisibility,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n repoVisibility = 'private',\n deleteBranchOnMerge = false,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n return newRepo.clone_url;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.requireCodeOwnerReviews","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.repoVisibility","inputProps.deleteBranchOnMerge","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings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A;AAAA,OACV,CAAA;AAED,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,iBAAA;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;;;;"}
@@ -17,38 +17,31 @@ function createGithubRepoPushAction(options) {
17
17
  examples: githubRepoPush_examples.examples,
18
18
  schema: {
19
19
  input: {
20
- type: "object",
21
- required: ["repoUrl"],
22
- properties: {
23
- repoUrl: inputProperties.repoUrl,
24
- requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
25
- dismissStaleReviews: inputProperties.dismissStaleReviews,
26
- requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
27
- bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
28
- requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
29
- restrictions: inputProperties.restrictions,
30
- requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
31
- requiredConversationResolution: inputProperties.requiredConversationResolution,
32
- requireLastPushApproval: inputProperties.requireLastPushApproval,
33
- defaultBranch: inputProperties.defaultBranch,
34
- protectDefaultBranch: inputProperties.protectDefaultBranch,
35
- protectEnforceAdmins: inputProperties.protectEnforceAdmins,
36
- gitCommitMessage: inputProperties.gitCommitMessage,
37
- gitAuthorName: inputProperties.gitAuthorName,
38
- gitAuthorEmail: inputProperties.gitAuthorEmail,
39
- sourcePath: inputProperties.sourcePath,
40
- token: inputProperties.token,
41
- requiredCommitSigning: inputProperties.requiredCommitSigning,
42
- requiredLinearHistory: inputProperties.requiredLinearHistory
43
- }
20
+ repoUrl: inputProperties.repoUrl,
21
+ requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
22
+ dismissStaleReviews: inputProperties.dismissStaleReviews,
23
+ requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
24
+ bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
25
+ requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
26
+ restrictions: inputProperties.restrictions,
27
+ requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
28
+ requiredConversationResolution: inputProperties.requiredConversationResolution,
29
+ requireLastPushApproval: inputProperties.requireLastPushApproval,
30
+ defaultBranch: inputProperties.defaultBranch,
31
+ protectDefaultBranch: inputProperties.protectDefaultBranch,
32
+ protectEnforceAdmins: inputProperties.protectEnforceAdmins,
33
+ gitCommitMessage: inputProperties.gitCommitMessage,
34
+ gitAuthorName: inputProperties.gitAuthorName,
35
+ gitAuthorEmail: inputProperties.gitAuthorEmail,
36
+ sourcePath: inputProperties.sourcePath,
37
+ token: inputProperties.token,
38
+ requiredCommitSigning: inputProperties.requiredCommitSigning,
39
+ requiredLinearHistory: inputProperties.requiredLinearHistory
44
40
  },
45
41
  output: {
46
- type: "object",
47
- properties: {
48
- remoteUrl: outputProperties.remoteUrl,
49
- repoContentsUrl: outputProperties.repoContentsUrl,
50
- commitHash: outputProperties.commitHash
51
- }
42
+ remoteUrl: outputProperties.remoteUrl,
43
+ repoContentsUrl: outputProperties.repoContentsUrl,
44
+ commitHash: outputProperties.commitHash
52
45
  }
53
46
  },
54
47
  async handler(ctx) {
@@ -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 = 'main',\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({\n ...octokitOptions,\n log: ctx.logger,\n });\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;AAAA,UACxC,8BAA8BC,4CAAW;AAAA,UACzC,cAAcC,4BAAW;AAAA,UACzB,6BAA6BC,2CAAW;AAAA,UACxC,gCACEC,8CAAW;AAAA,UACb,yBAAyBC,uCAAW;AAAA,UACpC,eAAeC,6BAAW;AAAA,UAC1B,sBAAsBC,oCAAW;AAAA,UACjC,sBAAsBC,oCAAW;AAAA,UACjC,kBAAkBC,gCAAW;AAAA,UAC7B,eAAeC,6BAAW;AAAA,UAC1B,gBAAgBC,8B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ACT,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;;;;"}
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 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 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 output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n defaultBranch = 'main',\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({\n ...octokitOptions,\n log: ctx.logger,\n });\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,GA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