@backstage/plugin-scaffolder-backend-module-github 0.7.0 → 0.7.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 +16 -0
- package/dist/actions/github.cjs.js +4 -1
- package/dist/actions/github.cjs.js.map +1 -1
- package/dist/actions/githubActionsDispatch.cjs.js +12 -10
- package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
- package/dist/actions/githubAutolinks.cjs.js +12 -10
- package/dist/actions/githubAutolinks.cjs.js.map +1 -1
- package/dist/actions/githubBranchProtection.cjs.js +4 -1
- package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
- package/dist/actions/githubDeployKey.cjs.js +4 -1
- package/dist/actions/githubDeployKey.cjs.js.map +1 -1
- package/dist/actions/githubEnvironment.cjs.js +4 -1
- package/dist/actions/githubEnvironment.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.cjs.js +12 -10
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.cjs.js +4 -1
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.cjs.js +48 -1
- package/dist/actions/githubPullRequest.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.examples.cjs.js +18 -0
- package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -1
- package/dist/actions/githubRepoCreate.cjs.js +4 -1
- package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
- package/dist/actions/githubRepoPush.cjs.js +4 -1
- package/dist/actions/githubRepoPush.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.cjs.js +12 -10
- package/dist/actions/githubWebhook.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n buildType: {\n title: 'Build Type',\n type: 'string',\n default: 'workflow',\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n enum: ['legacy', 'workflow'],\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n default: 'main',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n default: '/',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n enum: ['/', '/docs'],\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit(octokitOptions);\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await ctx.checkpoint({\n key: `enabled.github.pages.${owner}.${repo}`,\n fn: async () => {\n await client.request('POST /repos/{owner}/{repo}/pages', {\n owner: owner,\n repo: repo,\n build_type: buildType,\n source: {\n branch: sourceBranch,\n path: sourcePath,\n },\n headers: {\n 'X-GitHub-Api-Version': '2022-11-28',\n },\n });\n },\n });\n\n ctx.logger.info('Completed enabling GitHub Pages');\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,cACJC,mCAAA;AAAA,IACA,WAAa,EAAA,wCAAA;AAAA,IACb,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAA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AA,aAAA;AAAA,QACP,IAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAM,MAAA,MAAA,GAAS,IAAIC,
|
|
1
|
+
{"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n buildType: {\n title: 'Build Type',\n type: 'string',\n default: 'workflow',\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n enum: ['legacy', 'workflow'],\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n default: 'main',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n default: '/',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n enum: ['/', '/docs'],\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await ctx.checkpoint({\n key: `enabled.github.pages.${owner}.${repo}`,\n fn: async () => {\n await client.request('POST /repos/{owner}/{repo}/pages', {\n owner: owner,\n repo: repo,\n build_type: buildType,\n source: {\n branch: sourceBranch,\n path: sourcePath,\n },\n headers: {\n 'X-GitHub-Api-Version': '2022-11-28',\n },\n });\n },\n });\n\n ctx.logger.info('Completed enabling GitHub Pages');\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,cACJC,mCAAA;AAA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107
|
description: "The users that will be added as reviewers to the pull request"
|
|
108
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
|
+
},
|
|
109
117
|
teamReviewers: {
|
|
110
118
|
title: "Pull Request Team Reviewers",
|
|
111
119
|
type: "array",
|
|
@@ -184,6 +192,7 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
184
192
|
sourcePath,
|
|
185
193
|
token: providedToken,
|
|
186
194
|
reviewers,
|
|
195
|
+
assignees,
|
|
187
196
|
teamReviewers,
|
|
188
197
|
commitMessage,
|
|
189
198
|
update,
|
|
@@ -312,8 +321,8 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
312
321
|
throw new GithubResponseError("null response from Github");
|
|
313
322
|
}
|
|
314
323
|
const pullRequestNumber = pr.number;
|
|
324
|
+
const pullRequest = { owner, repo, number: pullRequestNumber };
|
|
315
325
|
if (reviewers || teamReviewers) {
|
|
316
|
-
const pullRequest = { owner, repo, number: pullRequestNumber };
|
|
317
326
|
await requestReviewersOnPullRequest(
|
|
318
327
|
pullRequest,
|
|
319
328
|
reviewers,
|
|
@@ -323,6 +332,20 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
323
332
|
ctx.checkpoint
|
|
324
333
|
);
|
|
325
334
|
}
|
|
335
|
+
if (assignees) {
|
|
336
|
+
if (assignees.length > 10) {
|
|
337
|
+
ctx.logger.warn(
|
|
338
|
+
"Assignees list is too long, only the first 10 will be used."
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
await addAssigneesToPullRequest(
|
|
342
|
+
pullRequest,
|
|
343
|
+
assignees,
|
|
344
|
+
client,
|
|
345
|
+
ctx.logger,
|
|
346
|
+
ctx.checkpoint
|
|
347
|
+
);
|
|
348
|
+
}
|
|
326
349
|
const targetBranch = pr.base.ref;
|
|
327
350
|
ctx.output("targetBranchName", targetBranch);
|
|
328
351
|
ctx.output("remoteUrl", pr.html_url);
|
|
@@ -332,6 +355,30 @@ const createPublishGithubPullRequestAction = (options) => {
|
|
|
332
355
|
}
|
|
333
356
|
}
|
|
334
357
|
});
|
|
358
|
+
async function addAssigneesToPullRequest(pr, assignees, client, logger, checkpoint) {
|
|
359
|
+
try {
|
|
360
|
+
await checkpoint({
|
|
361
|
+
key: `add.assignees.${pr.owner}.${pr.repo}.${pr.number}`,
|
|
362
|
+
fn: async () => {
|
|
363
|
+
const result = await client.rest.issues.addAssignees({
|
|
364
|
+
owner: pr.owner,
|
|
365
|
+
repo: pr.repo,
|
|
366
|
+
issue_number: pr.number,
|
|
367
|
+
assignees
|
|
368
|
+
});
|
|
369
|
+
const addedAssignees = result.data.assignees?.join(", ") ?? "";
|
|
370
|
+
logger.info(
|
|
371
|
+
`Added assignees [${addedAssignees}] to Pull request ${pr.number}`
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
} catch (e) {
|
|
376
|
+
logger.error(
|
|
377
|
+
`Failure when adding assignees to Pull request ${pr.number}`,
|
|
378
|
+
e
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
335
382
|
async function requestReviewersOnPullRequest(pr, reviewers, teamReviewers, client, logger, checkpoint) {
|
|
336
383
|
try {
|
|
337
384
|
await checkpoint({
|
|
@@ -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 teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n createWhenEmpty?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the pull request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n },\n createWhenEmpty: {\n type: 'boolean',\n title: 'Create When Empty',\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n },\n },\n },\n output: {\n required: [],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n\n const pr = await ctx.checkpoint({\n key: `create.pr.${owner}.${repo}.${branchName}`,\n fn: async () => {\n const response = await client.createPullRequest(createOptions);\n if (!response) {\n return null;\n }\n\n return {\n base: response?.data.base,\n html_url: response?.data.html_url,\n number: response?.data.number,\n };\n },\n });\n\n if (createWhenEmpty === false && !pr) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!pr) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = pr.number;\n if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n ctx.checkpoint,\n );\n }\n\n const targetBranch = pr.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', pr.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n checkpoint: <T extends JsonValue | void>(opts: {\n key: string;\n fn: () => Promise<T> | T;\n }) => Promise<T>,\n ) {\n try {\n await checkpoint({\n key: `request.reviewers.${pr.owner}.${pr.repo}.${pr.number}`,\n fn: async () => {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers\n ? [...new Set(teamReviewers)]\n : undefined,\n });\n\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n },\n });\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"mappings":";;;;;;;;;;;;;;;AAyCA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;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,OAC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AAK,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 { 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;AA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A,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;;;;;"}
|
|
@@ -272,6 +272,24 @@ const examples = [
|
|
|
272
272
|
}
|
|
273
273
|
]
|
|
274
274
|
})
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
description: "Create a pull request with assignees",
|
|
278
|
+
example: yaml__default.default.stringify({
|
|
279
|
+
steps: [
|
|
280
|
+
{
|
|
281
|
+
action: "publish:github:pull-request",
|
|
282
|
+
name: "Create a pull request with reviewers",
|
|
283
|
+
input: {
|
|
284
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
285
|
+
branchName: "new-app",
|
|
286
|
+
title: "Create my new app",
|
|
287
|
+
description: "This PR is really good",
|
|
288
|
+
assignees: ["foobar"]
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
})
|
|
275
293
|
}
|
|
276
294
|
];
|
|
277
295
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubPullRequest.examples.cjs.js","sources":["../../src/actions/githubPullRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target branch name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target branch name',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request as draft',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request as draft',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n draft: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetPath: 'targetPath',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with source path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with source path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n sourcePath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n reviewers: ['foobar'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with team reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with team reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n teamReviewers: ['team-foo'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with commit message',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n commitMessage: 'Custom commit message',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name and email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorEmail will be 'scaffolder@backstage.io'\n // once one author attribute has been set we need to set both\n gitAuthorName: 'Foo Bar',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorName will be 'Scaffolder'\n // once one author attribute has been set we need to set both\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Do not create empty pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n createWhenEmpty: false,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with all parameters',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n draft: true,\n targetPath: 'targetPath',\n sourcePath: 'source',\n token: 'gph_YourGitHubToken',\n reviewers: ['foobar'],\n teamReviewers: ['team-foo'],\n commitMessage: 'Commit for foo changes',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@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AA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,eAAiB,EAAA;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,2CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,uBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,gBAAkB,EAAA,MAAA;AAAA,YAClB,KAAO,EAAA,IAAA;AAAA,YACP,UAAY,EAAA,YAAA;AAAA,YACZ,UAAY,EAAA,QAAA;AAAA,YACZ,KAAO,EAAA,qBAAA;AAAA,YACP,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,YACpB,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,YAC1B,aAAe,EAAA,wBAAA;AAAA,YACf,aAAe,EAAA,SAAA;AAAA,YACf,cAAgB,EAAA,iBAAA;AAAA,YAChB,eAAiB,EAAA;AAAA;AACnB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"githubPullRequest.examples.cjs.js","sources":["../../src/actions/githubPullRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target branch name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target branch name',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request as draft',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request as draft',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n draft: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with target path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with target path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetPath: 'targetPath',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with source path',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with source path',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n sourcePath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n reviewers: ['foobar'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with team reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with team reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n teamReviewers: ['team-foo'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with commit message',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n commitMessage: 'Custom commit message',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name and email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author name',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorEmail will be 'scaffolder@backstage.io'\n // once one author attribute has been set we need to set both\n gitAuthorName: 'Foo Bar',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with a git author email',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n // gitAuthorName will be 'Scaffolder'\n // once one author attribute has been set we need to set both\n gitAuthorEmail: 'foo@bar.example',\n },\n },\n ],\n }),\n },\n {\n description: 'Do not create empty pull request',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n createWhenEmpty: false,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with all parameters',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n targetBranchName: 'test',\n draft: true,\n targetPath: 'targetPath',\n sourcePath: 'source',\n token: 'gph_YourGitHubToken',\n reviewers: ['foobar'],\n teamReviewers: ['team-foo'],\n commitMessage: 'Commit for foo changes',\n gitAuthorName: 'Foo Bar',\n gitAuthorEmail: 'foo@bar.example',\n createWhenEmpty: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a pull request with assignees',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:github:pull-request',\n name: 'Create a pull request with reviewers',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branchName: 'new-app',\n title: 'Create my new app',\n description: 'This PR is really good',\n assignees: ['foobar'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACt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GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,2CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,uBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,gBAAkB,EAAA,MAAA;AAAA,YAClB,KAAO,EAAA,IAAA;AAAA,YACP,UAAY,EAAA,YAAA;AAAA,YACZ,UAAY,EAAA,QAAA;AAAA,YACZ,KAAO,EAAA,qBAAA;AAAA,YACP,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,YACpB,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,YAC1B,aAAe,EAAA,wBAAA;AAAA,YACf,aAAe,EAAA,SAAA;AAAA,YACf,cAAgB,EAAA,iBAAA;AAAA,YAChB,eAAiB,EAAA;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,sCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,sCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,SAAA;AAAA,YACZ,KAAO,EAAA,mBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,SAAA,EAAW,CAAC,QAAQ;AAAA;AACtB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -102,7 +102,10 @@ function createGithubRepoCreateAction(options) {
|
|
|
102
102
|
owner,
|
|
103
103
|
repo
|
|
104
104
|
});
|
|
105
|
-
const client = new octokit.Octokit(
|
|
105
|
+
const client = new octokit.Octokit({
|
|
106
|
+
...octokitOptions,
|
|
107
|
+
log: ctx.logger
|
|
108
|
+
});
|
|
106
109
|
const remoteUrl = await ctx.checkpoint({
|
|
107
110
|
key: `create.repo.and.topics.${owner}.${repo}`,
|
|
108
111
|
fn: async () => {
|
|
@@ -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(octokitOptions);\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n 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,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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;;;;"}
|
|
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,sCAAW;AAAA,UACnC,0BAA0BC,wCAAW;AAAA,UACrC,kBAAkBC,gCAAW;AAAA,UAC7B,gBAAgBC,8BAAW;AAAA,UAC3B,mBAAmB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CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AAAA;AACnC,GACD,CAAA;AACH;;;;"}
|
|
@@ -85,7 +85,10 @@ function createGithubRepoPushAction(options) {
|
|
|
85
85
|
owner,
|
|
86
86
|
repo
|
|
87
87
|
});
|
|
88
|
-
const client = new octokit.Octokit(
|
|
88
|
+
const client = new octokit.Octokit({
|
|
89
|
+
...octokitOptions,
|
|
90
|
+
log: ctx.logger
|
|
91
|
+
});
|
|
89
92
|
const targetRepo = await client.rest.repos.get({ owner, repo });
|
|
90
93
|
const remoteUrl = targetRepo.data.clone_url;
|
|
91
94
|
const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;
|
|
@@ -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(octokitOptions);\n\n const targetRepo = await client.rest.repos.get({ owner, repo });\n\n const remoteUrl = targetRepo.data.clone_url;\n const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;\n\n const commitHash = await ctx.checkpoint({\n key: `init.repo.publish.${owner}.${client}.${repo}`,\n fn: async () => {\n const { commitHash: hash } = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n return hash;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('commitHash', commitHash);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.sourcePath","inputProps.token","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AAuCO,SAAS,2BAA2B,OAIxC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAQ,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAE5D,EAAA,OAAOA,yCAkCJ,CAAA;AAAA,IACD,EAAI,EAAA,kBAAA;AAAA,IACJ,WACE,EAAA,mFAAA;AAAA,cACFC,gCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,SAASC,uBAAW;AAAA,UACpB,yBAAyBC,uCAAW;AAAA,UACpC,qBAAqBC,mCAAW;AAAA,UAChC,6BAA6BC,2CAAW;AAAA,UACxC,6BAA6BC,2CAAW;AAAA,UACxC,8BAA8BC,4CAAW;AAAA,UACzC,cAAcC,4BAAW;AAAA,UACzB,6BAA6BC,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AA;AAAA,YACA,GAAI,CAAA,MAAA;AAAA,YACJ,gBAAA;AAAA,YACA,aAAA;AAAA,YACA,cAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACF;AACA,UAAO,OAAA,IAAA;AAAA;AACT,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,cAAc,UAAU,CAAA;AAAA;AACrC,GACD,CAAA;AACH;;;;"}
|
|
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;AA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BAAA;AAAA,YACA,MAAA;AAAA,YACA,GAAI,CAAA,MAAA;AAAA,YACJ,gBAAA;AAAA,YACA,aAAA;AAAA,YACA,cAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACF;AACA,UAAO,OAAA,IAAA;AAAA;AACT,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,cAAc,UAAU,CAAA;AAAA;AACrC,GACD,CAAA;AACH;;;;"}
|
|
@@ -98,16 +98,18 @@ function createGithubWebhookAction(options) {
|
|
|
98
98
|
if (!owner) {
|
|
99
99
|
throw new errors.InputError("Invalid repository owner provided in repoUrl");
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
const octokitOptions = await util.getOctokitOptions({
|
|
102
|
+
integrations,
|
|
103
|
+
credentialsProvider: githubCredentialsProvider,
|
|
104
|
+
host,
|
|
105
|
+
owner,
|
|
106
|
+
repo,
|
|
107
|
+
token: providedToken
|
|
108
|
+
});
|
|
109
|
+
const client = new octokit.Octokit({
|
|
110
|
+
...octokitOptions,
|
|
111
|
+
log: ctx.logger
|
|
112
|
+
});
|
|
111
113
|
if (ctx.isDryRun) {
|
|
112
114
|
ctx.logger.info(`Dry run complete`);
|
|
113
115
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n type: 'array',\n default: ['push'],\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n default: true,\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n default: 'form',\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n default: false,\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const
|
|
1
|
+
{"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n type: 'string',\n },\n webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n type: 'array',\n default: ['push'],\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n default: true,\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n default: 'form',\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n default: false,\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n\n await ctx.checkpoint({\n key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,\n fn: async () => {\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n },\n });\n\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAIvC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAsB,EAAA,yBAAA,EAC1C,GAAA,OAAA;AAEF,EAAM,MAAA,UAAA,GAAaA,2BAAkB,MAAO,CAAA,CAAA,KAAA,KAAS,CAAC,KAAM,CAAA,QAAA,CAAS,GAA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D,MAAM,MAAA,MAAA,GAAS,IAAIC,eAAQ,CAAA;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAI,CAAA;AAAA,OACV,CAAA;AAGD,MAAA,IAAI,IAAI,QAAU,EAAA;AAChB,QAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAkB,gBAAA,CAAA,CAAA;AAClC,QAAA;AAAA;AAGF,MAAI,IAAA;AACF,QAAM,MAAA,YAAA,GAAe,cAAc,GAAM,GAAA,GAAA;AAEzC,QAAA,MAAM,IAAI,UAAW,CAAA;AAAA,UACnB,KAAK,CAAmB,gBAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,IAAI,UAAU,CAAA,CAAA;AAAA,UACnD,IAAI,YAAY;AACd,YAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,aAAc,CAAA;AAAA,cACpC,KAAA;AAAA,cACA,IAAA;AAAA,cACA,MAAQ,EAAA;AAAA,gBACN,GAAK,EAAA,UAAA;AAAA,gBACL,YAAc,EAAA,WAAA;AAAA,gBACd,MAAQ,EAAA,aAAA;AAAA,gBACR;AAAA,eACF;AAAA,cACA,MAAA;AAAA,cACA;AAAA,aACD,CAAA;AAAA;AACH,SACD,CAAA;AAED,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAAwB,sBAAA,CAAA,CAAA;AAAA,eACvD,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,2BAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACzE;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -274,6 +274,7 @@ declare const createPublishGithubPullRequestAction: (options: CreateGithubPullRe
|
|
|
274
274
|
sourcePath?: string;
|
|
275
275
|
token?: string;
|
|
276
276
|
reviewers?: string[];
|
|
277
|
+
assignees?: string[];
|
|
277
278
|
teamReviewers?: string[];
|
|
278
279
|
commitMessage?: string;
|
|
279
280
|
update?: boolean;
|