@backstage/plugin-scaffolder-backend-module-github 0.8.0-next.2 → 0.8.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.8.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f36bcf9: Added support for file deletion to `publish:github:pull-request` action.
|
|
8
|
+
|
|
9
|
+
Example usage:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
- action: publish:github:pull-request
|
|
13
|
+
id: clean-up-pr
|
|
14
|
+
input:
|
|
15
|
+
description: This is the description
|
|
16
|
+
+ filesToDelete:
|
|
17
|
+
+ - outdated/changelog.md
|
|
18
|
+
+ - sample-file.txt
|
|
19
|
+
owner: owner
|
|
20
|
+
repo: repo
|
|
21
|
+
title: Title Goes Here
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/plugin-scaffolder-node@0.9.1-next.0
|
|
27
|
+
- @backstage/integration@1.17.1-next.0
|
|
28
|
+
- @backstage/backend-plugin-api@1.4.0
|
|
29
|
+
- @backstage/plugin-catalog-node@1.17.1
|
|
30
|
+
- @backstage/catalog-model@1.7.4
|
|
31
|
+
- @backstage/config@1.3.2
|
|
32
|
+
- @backstage/errors@1.2.7
|
|
33
|
+
- @backstage/types@1.2.1
|
|
34
|
+
|
|
35
|
+
## 0.8.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 5863b04: **BREAKING CHANGES**
|
|
40
|
+
|
|
41
|
+
The `createGithubEnvironmentAction` action no longer requires an `AuthService`, and now accepts a `CatalogService` instead of `CatalogClient`.
|
|
42
|
+
|
|
43
|
+
Unless you're providing your own override action to the default, this should be a non-breaking change.
|
|
44
|
+
|
|
45
|
+
You can migrate using the following if you're getting typescript errors:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { catalogServiceRef } from '@backstage/plugin-catalog-node';
|
|
49
|
+
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
|
|
50
|
+
|
|
51
|
+
export const myModule = createBackendModule({
|
|
52
|
+
pluginId: 'scaffolder',
|
|
53
|
+
moduleId: 'test',
|
|
54
|
+
register({ registerInit }) {
|
|
55
|
+
registerInit({
|
|
56
|
+
deps: {
|
|
57
|
+
scaffolder: scaffolderActionsExtensionPoint,
|
|
58
|
+
catalog: catalogServiceRef,
|
|
59
|
+
},
|
|
60
|
+
async init({ scaffolder, catalog }) {
|
|
61
|
+
scaffolder.addActions(
|
|
62
|
+
createGithubEnvironmentAction({
|
|
63
|
+
catalog,
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 575c76b: Migrate to using new actions
|
|
75
|
+
- Updated dependencies
|
|
76
|
+
- @backstage/plugin-scaffolder-node@0.9.0
|
|
77
|
+
- @backstage/plugin-catalog-node@1.17.1
|
|
78
|
+
- @backstage/backend-plugin-api@1.4.0
|
|
79
|
+
- @backstage/catalog-model@1.7.4
|
|
80
|
+
- @backstage/config@1.3.2
|
|
81
|
+
- @backstage/errors@1.2.7
|
|
82
|
+
- @backstage/integration@1.17.0
|
|
83
|
+
- @backstage/types@1.2.1
|
|
84
|
+
|
|
3
85
|
## 0.8.0-next.2
|
|
4
86
|
|
|
5
87
|
### Minor Changes
|
|
@@ -56,6 +56,9 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
56
56
|
branchName: (z) => z.string({
|
|
57
57
|
description: "The name for the branch"
|
|
58
58
|
}),
|
|
59
|
+
filesToDelete: (z) => z.array(z.string(), {
|
|
60
|
+
description: "List of files that will be deleted"
|
|
61
|
+
}).optional(),
|
|
59
62
|
targetBranchName: (z) => z.string({
|
|
60
63
|
description: "The target branch name of the pull request"
|
|
61
64
|
}).optional(),
|
|
@@ -124,6 +127,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
124
127
|
const {
|
|
125
128
|
repoUrl,
|
|
126
129
|
branchName,
|
|
130
|
+
filesToDelete,
|
|
127
131
|
targetBranchName,
|
|
128
132
|
title,
|
|
129
133
|
description,
|
|
@@ -166,8 +170,8 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
166
170
|
return "100644";
|
|
167
171
|
};
|
|
168
172
|
const determineFileEncoding = (file) => file.symlink ? "utf-8" : "base64";
|
|
169
|
-
const files = Object.fromEntries(
|
|
170
|
-
directoryContents.map((file) => [
|
|
173
|
+
const files = Object.fromEntries([
|
|
174
|
+
...directoryContents.map((file) => [
|
|
171
175
|
targetPath ? path__default.default.posix.join(targetPath, file.path) : file.path,
|
|
172
176
|
{
|
|
173
177
|
// See the properties of tree items
|
|
@@ -183,8 +187,14 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
183
187
|
encoding: determineFileEncoding(file),
|
|
184
188
|
content: file.content.toString(determineFileEncoding(file))
|
|
185
189
|
}
|
|
190
|
+
]),
|
|
191
|
+
// order of arrays is important so filesToDelete will overwrite
|
|
192
|
+
// changes from files above
|
|
193
|
+
...(filesToDelete || []).map((filePath) => [
|
|
194
|
+
targetPath ? path__default.default.posix.join(targetPath, filePath) : filePath,
|
|
195
|
+
octokitPluginCreatePullRequest.DELETE_FILE
|
|
186
196
|
])
|
|
187
|
-
);
|
|
197
|
+
]);
|
|
188
198
|
if (ctx.isDryRun) {
|
|
189
199
|
ctx.logger.info(`Performing dry run of creating pull request`);
|
|
190
200
|
ctx.output("targetBranchName", branchName);
|
|
@@ -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 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,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,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;;;;;"}
|
|
1
|
+
{"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport {\n createPullRequest,\n DELETE_FILE,\n} from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { JsonValue } from '@backstage/types';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n branchName: z =>\n z.string({\n description: 'The name for the branch',\n }),\n filesToDelete: z =>\n z\n .array(z.string(), {\n description: 'List of files that will be deleted',\n })\n .optional(),\n targetBranchName: z =>\n z\n .string({\n description: 'The target branch name of the pull request',\n })\n .optional(),\n title: z =>\n z.string({\n description: 'The name for the pull request',\n }),\n description: z =>\n z.string({\n description: 'The description of the pull request',\n }),\n draft: z =>\n z\n .boolean({\n description: 'Create a draft pull request',\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as reviewers to the pull request',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'The users that will be added as assignees to the pull request',\n })\n .optional(),\n teamReviewers: z =>\n z\n .array(z.string(), {\n description:\n 'The teams that will be added as reviewers to the pull request',\n })\n .optional(),\n commitMessage: z =>\n z\n .string({\n description: 'The commit message for the pull request commit',\n })\n .optional(),\n update: z =>\n z\n .boolean({\n description: 'Update pull request if already exists',\n })\n .optional(),\n forceFork: z =>\n z\n .boolean({\n description: 'Create pull request from a fork',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n })\n .optional(),\n forceEmptyGitAuthor: z =>\n z\n .boolean({\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n })\n .optional(),\n createWhenEmpty: z =>\n z\n .boolean({\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n })\n .optional(),\n },\n output: {\n targetBranchName: z =>\n z.string({\n description: 'Target branch name of the merge request',\n }),\n remoteUrl: z =>\n z.string({\n description: 'Link to the pull request in Github',\n }),\n pullRequestNumber: z =>\n z.number({\n description: 'The pull request number',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n filesToDelete,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n assignees,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries([\n ...directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n // order of arrays is important so filesToDelete will overwrite\n // changes from files above\n ...(filesToDelete || []).map(filePath => [\n targetPath ? path.posix.join(targetPath, filePath) : filePath,\n DELETE_FILE,\n ]),\n ]);\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n const pullRequest = { owner, repo, number: pullRequestNumber };\n if (reviewers || teamReviewers) {\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n if (assignees) {\n if (assignees.length > 10) {\n ctx.logger.warn(\n 'Assignees list is too long, only the first 10 will be used.',\n );\n }\n await addAssigneesToPullRequest(\n pullRequest,\n assignees,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function addAssigneesToPullRequest(\n pr: GithubPullRequest,\n assignees: string[],\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.issues.addAssignees({\n owner: pr.owner,\n repo: pr.repo,\n issue_number: pr.number,\n assignees,\n });\n\n const addedAssignees = result.data.assignees?.join(', ') ?? '';\n\n logger.info(\n `Added assignees [${addedAssignees}] to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding assignees to Pull request ${pr.number}`,\n e,\n );\n }\n }\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path","DELETE_FILE"],"mappings":";;;;;;;;;;;;;;;AA4CA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OA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C,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;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,7 @@ declare const createPublishGithubPullRequestAction: (options: CreateGithubPullRe
|
|
|
263
263
|
branchName: string;
|
|
264
264
|
title: string;
|
|
265
265
|
description: string;
|
|
266
|
+
filesToDelete?: string[] | undefined;
|
|
266
267
|
targetBranchName?: string | undefined;
|
|
267
268
|
draft?: boolean | undefined;
|
|
268
269
|
sourcePath?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-github",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-next.0",
|
|
4
4
|
"description": "The github module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"test": "backstage-cli package test"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@backstage/backend-plugin-api": "1.4.0
|
|
53
|
+
"@backstage/backend-plugin-api": "1.4.0",
|
|
54
54
|
"@backstage/catalog-model": "1.7.4",
|
|
55
55
|
"@backstage/config": "1.3.2",
|
|
56
56
|
"@backstage/errors": "1.2.7",
|
|
57
|
-
"@backstage/integration": "1.17.0",
|
|
58
|
-
"@backstage/plugin-catalog-node": "1.17.1
|
|
59
|
-
"@backstage/plugin-scaffolder-node": "0.9.
|
|
57
|
+
"@backstage/integration": "1.17.1-next.0",
|
|
58
|
+
"@backstage/plugin-catalog-node": "1.17.1",
|
|
59
|
+
"@backstage/plugin-scaffolder-node": "0.9.1-next.0",
|
|
60
60
|
"@backstage/types": "1.2.1",
|
|
61
61
|
"@octokit/webhooks": "^10.9.2",
|
|
62
62
|
"libsodium-wrappers": "^0.7.11",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"zod": "^3.22.4"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@backstage/backend-test-utils": "1.
|
|
70
|
-
"@backstage/cli": "0.33.
|
|
71
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.3.
|
|
69
|
+
"@backstage/backend-test-utils": "1.7.0-next.0",
|
|
70
|
+
"@backstage/cli": "0.33.1-next.0",
|
|
71
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.3.1-next.0",
|
|
72
72
|
"@types/libsodium-wrappers": "^0.7.10",
|
|
73
73
|
"fs-extra": "^11.2.0",
|
|
74
74
|
"jsonschema": "^1.2.6"
|