@backstage/plugin-scaffolder-backend-module-github 0.7.2-next.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/dist/actions/github.cjs.js +45 -52
  3. package/dist/actions/github.cjs.js.map +1 -1
  4. package/dist/actions/githubActionsDispatch.cjs.js +15 -29
  5. package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
  6. package/dist/actions/githubAutolinks.cjs.js +15 -30
  7. package/dist/actions/githubAutolinks.cjs.js.map +1 -1
  8. package/dist/actions/githubBranchProtection.cjs.js +15 -23
  9. package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
  10. package/dist/actions/githubDeployKey.cjs.js +21 -41
  11. package/dist/actions/githubDeployKey.cjs.js.map +1 -1
  12. package/dist/actions/githubEnvironment.cjs.js +47 -89
  13. package/dist/actions/githubEnvironment.cjs.js.map +1 -1
  14. package/dist/actions/githubIssuesLabel.cjs.js +12 -27
  15. package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
  16. package/dist/actions/githubPagesEnable.cjs.js +15 -34
  17. package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
  18. package/dist/actions/githubPullRequest.cjs.js +66 -126
  19. package/dist/actions/githubPullRequest.cjs.js.map +1 -1
  20. package/dist/actions/githubRepoCreate.cjs.js +35 -42
  21. package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
  22. package/dist/actions/githubRepoPush.cjs.js +23 -30
  23. package/dist/actions/githubRepoPush.cjs.js.map +1 -1
  24. package/dist/actions/githubWebhook.cjs.js +29 -63
  25. package/dist/actions/githubWebhook.cjs.js.map +1 -1
  26. package/dist/actions/inputProperties.cjs.js +145 -281
  27. package/dist/actions/inputProperties.cjs.js.map +1 -1
  28. package/dist/actions/outputProperties.cjs.js +9 -12
  29. package/dist/actions/outputProperties.cjs.js.map +1 -1
  30. package/dist/index.d.ts +210 -211
  31. package/dist/module.cjs.js +4 -9
  32. package/dist/module.cjs.js.map +1 -1
  33. package/package.json +14 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,105 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5863b04: **BREAKING CHANGES**
8
+
9
+ The `createGithubEnvironmentAction` action no longer requires an `AuthService`, and now accepts a `CatalogService` instead of `CatalogClient`.
10
+
11
+ Unless you're providing your own override action to the default, this should be a non-breaking change.
12
+
13
+ You can migrate using the following if you're getting typescript errors:
14
+
15
+ ```ts
16
+ import { catalogServiceRef } from '@backstage/plugin-catalog-node';
17
+ import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
18
+
19
+ export const myModule = createBackendModule({
20
+ pluginId: 'scaffolder',
21
+ moduleId: 'test',
22
+ register({ registerInit }) {
23
+ registerInit({
24
+ deps: {
25
+ scaffolder: scaffolderActionsExtensionPoint,
26
+ catalog: catalogServiceRef,
27
+ },
28
+ async init({ scaffolder, catalog }) {
29
+ scaffolder.addActions(
30
+ createGithubEnvironmentAction({
31
+ catalog,
32
+ }),
33
+ );
34
+ },
35
+ });
36
+ },
37
+ });
38
+ ```
39
+
40
+ ### Patch Changes
41
+
42
+ - 575c76b: Migrate to using new actions
43
+ - Updated dependencies
44
+ - @backstage/plugin-scaffolder-node@0.9.0
45
+ - @backstage/plugin-catalog-node@1.17.1
46
+ - @backstage/backend-plugin-api@1.4.0
47
+ - @backstage/catalog-model@1.7.4
48
+ - @backstage/config@1.3.2
49
+ - @backstage/errors@1.2.7
50
+ - @backstage/integration@1.17.0
51
+ - @backstage/types@1.2.1
52
+
53
+ ## 0.8.0-next.2
54
+
55
+ ### Minor Changes
56
+
57
+ - 5863b04: **BREAKING CHANGES**
58
+
59
+ The `createGithubEnvironmentAction` action no longer requires an `AuthService`, and now accepts a `CatalogService` instead of `CatalogClient`.
60
+
61
+ Unless you're providing your own override action to the default, this should be a non-breaking change.
62
+
63
+ You can migrate using the following if you're getting typescript errors:
64
+
65
+ ```ts
66
+ import { catalogServiceRef } from '@backstage/plugin-catalog-node';
67
+ import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
68
+
69
+ export const myModule = createBackendModule({
70
+ pluginId: 'scaffolder',
71
+ moduleId: 'test',
72
+ register({ registerInit }) {
73
+ registerInit({
74
+ deps: {
75
+ scaffolder: scaffolderActionsExtensionPoint,
76
+ catalog: catalogServiceRef,
77
+ },
78
+ async init({ scaffolder, catalog }) {
79
+ scaffolder.addActions(
80
+ createGithubEnvironmentAction({
81
+ catalog,
82
+ }),
83
+ );
84
+ },
85
+ });
86
+ },
87
+ });
88
+ ```
89
+
90
+ ### Patch Changes
91
+
92
+ - 575c76b: Migrate to using new actions
93
+ - Updated dependencies
94
+ - @backstage/plugin-scaffolder-node@0.9.0-next.2
95
+ - @backstage/backend-plugin-api@1.4.0-next.1
96
+ - @backstage/catalog-model@1.7.4
97
+ - @backstage/config@1.3.2
98
+ - @backstage/errors@1.2.7
99
+ - @backstage/integration@1.17.0
100
+ - @backstage/types@1.2.1
101
+ - @backstage/plugin-catalog-node@1.17.1-next.1
102
+
3
103
  ## 0.7.2-next.1
4
104
 
5
105
  ### Patch Changes
@@ -17,60 +17,53 @@ function createPublishGithubAction(options) {
17
17
  examples: github_examples.examples,
18
18
  schema: {
19
19
  input: {
20
- type: "object",
21
- required: ["repoUrl"],
22
- properties: {
23
- repoUrl: inputProperties.repoUrl,
24
- description: inputProperties.description,
25
- homepage: inputProperties.homepage,
26
- access: inputProperties.access,
27
- bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
28
- requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
29
- restrictions: inputProperties.restrictions,
30
- requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
31
- dismissStaleReviews: inputProperties.dismissStaleReviews,
32
- requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
33
- requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
34
- requiredConversationResolution: inputProperties.requiredConversationResolution,
35
- requireLastPushApproval: inputProperties.requireLastPushApproval,
36
- repoVisibility: inputProperties.repoVisibility,
37
- defaultBranch: inputProperties.defaultBranch,
38
- protectDefaultBranch: inputProperties.protectDefaultBranch,
39
- protectEnforceAdmins: inputProperties.protectEnforceAdmins,
40
- deleteBranchOnMerge: inputProperties.deleteBranchOnMerge,
41
- gitCommitMessage: inputProperties.gitCommitMessage,
42
- gitAuthorName: inputProperties.gitAuthorName,
43
- gitAuthorEmail: inputProperties.gitAuthorEmail,
44
- allowMergeCommit: inputProperties.allowMergeCommit,
45
- allowSquashMerge: inputProperties.allowSquashMerge,
46
- squashMergeCommitTitle: inputProperties.squashMergeCommitTitle,
47
- squashMergeCommitMessage: inputProperties.squashMergeCommitMessage,
48
- allowRebaseMerge: inputProperties.allowRebaseMerge,
49
- allowAutoMerge: inputProperties.allowAutoMerge,
50
- allowUpdateBranch: inputProperties.allowUpdateBranch,
51
- sourcePath: inputProperties.sourcePath,
52
- collaborators: inputProperties.collaborators,
53
- hasProjects: inputProperties.hasProjects,
54
- hasWiki: inputProperties.hasWiki,
55
- hasIssues: inputProperties.hasIssues,
56
- token: inputProperties.token,
57
- topics: inputProperties.topics,
58
- repoVariables: inputProperties.repoVariables,
59
- secrets: inputProperties.secrets,
60
- oidcCustomization: inputProperties.oidcCustomization,
61
- requiredCommitSigning: inputProperties.requiredCommitSigning,
62
- requiredLinearHistory: inputProperties.requiredLinearHistory,
63
- customProperties: inputProperties.customProperties,
64
- subscribe: inputProperties.subscribe
65
- }
20
+ repoUrl: inputProperties.repoUrl,
21
+ description: inputProperties.description,
22
+ homepage: inputProperties.homepage,
23
+ access: inputProperties.access,
24
+ bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
25
+ requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
26
+ restrictions: inputProperties.restrictions,
27
+ requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
28
+ dismissStaleReviews: inputProperties.dismissStaleReviews,
29
+ requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
30
+ requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
31
+ requiredConversationResolution: inputProperties.requiredConversationResolution,
32
+ requireLastPushApproval: inputProperties.requireLastPushApproval,
33
+ repoVisibility: inputProperties.repoVisibility,
34
+ defaultBranch: inputProperties.defaultBranch,
35
+ protectDefaultBranch: inputProperties.protectDefaultBranch,
36
+ protectEnforceAdmins: inputProperties.protectEnforceAdmins,
37
+ deleteBranchOnMerge: inputProperties.deleteBranchOnMerge,
38
+ gitCommitMessage: inputProperties.gitCommitMessage,
39
+ gitAuthorName: inputProperties.gitAuthorName,
40
+ gitAuthorEmail: inputProperties.gitAuthorEmail,
41
+ allowMergeCommit: inputProperties.allowMergeCommit,
42
+ allowSquashMerge: inputProperties.allowSquashMerge,
43
+ squashMergeCommitTitle: inputProperties.squashMergeCommitTitle,
44
+ squashMergeCommitMessage: inputProperties.squashMergeCommitMessage,
45
+ allowRebaseMerge: inputProperties.allowRebaseMerge,
46
+ allowAutoMerge: inputProperties.allowAutoMerge,
47
+ allowUpdateBranch: inputProperties.allowUpdateBranch,
48
+ sourcePath: inputProperties.sourcePath,
49
+ collaborators: inputProperties.collaborators,
50
+ hasProjects: inputProperties.hasProjects,
51
+ hasWiki: inputProperties.hasWiki,
52
+ hasIssues: inputProperties.hasIssues,
53
+ token: inputProperties.token,
54
+ topics: inputProperties.topics,
55
+ repoVariables: inputProperties.repoVariables,
56
+ secrets: inputProperties.secrets,
57
+ oidcCustomization: inputProperties.oidcCustomization,
58
+ requiredCommitSigning: inputProperties.requiredCommitSigning,
59
+ requiredLinearHistory: inputProperties.requiredLinearHistory,
60
+ customProperties: inputProperties.customProperties,
61
+ subscribe: inputProperties.subscribe
66
62
  },
67
63
  output: {
68
- type: "object",
69
- properties: {
70
- remoteUrl: outputProperties.remoteUrl,
71
- repoContentsUrl: outputProperties.repoContentsUrl,
72
- commitHash: outputProperties.commitHash
73
- }
64
+ remoteUrl: outputProperties.remoteUrl,
65
+ repoContentsUrl: outputProperties.repoContentsUrl,
66
+ commitHash: outputProperties.commitHash
74
67
  }
75
68
  },
76
69
  async handler(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"github.cjs.js","sources":["../../src/actions/github.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 {\n createGithubRepoWithCollaboratorsAndTopics,\n initRepoPushAndProtect,\n} from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './github.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 createPublishGithubAction(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 homepage?: string;\n access?: string;\n defaultBranch?: string;\n protectDefaultBranch?: boolean;\n protectEnforceAdmins?: boolean;\n deleteBranchOnMerge?: boolean;\n gitCommitMessage?: string;\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 sourcePath?: string;\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 requireCodeOwnerReviews?: boolean;\n dismissStaleReviews?: boolean;\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval?: 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 | undefined;\n hasWiki?: boolean | undefined;\n hasIssues?: boolean | undefined;\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 requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n customProperties?: { [key: string]: string };\n subscribe?: boolean;\n }>({\n id: 'publish:github',\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 description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n repoVisibility: inputProps.repoVisibility,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\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 sourcePath: inputProps.sourcePath,\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 commitHash: outputProps.commitHash,\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\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 repoVisibility = 'private',\n defaultBranch = 'main',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n deleteBranchOnMerge = false,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\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 token: providedToken,\n customProperties,\n subscribe = false,\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 const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.github.repo.${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\n return {\n remoteUrl: newRepo.clone_url,\n repoContentsUrl: `${newRepo.html_url}/blob/${defaultBranch}`,\n };\n },\n });\n\n const commitResult = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.repoVisibility","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.deleteBranchOnMerge","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.sourcePath","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","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit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A,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"github.cjs.js","sources":["../../src/actions/github.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 {\n createGithubRepoWithCollaboratorsAndTopics,\n initRepoPushAndProtect,\n} from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './github.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 createPublishGithubAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, config, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'publish:github',\n description:\n 'Initializes a git repository of contents in workspace and publishes it to GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n repoVisibility: inputProps.repoVisibility,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\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 sourcePath: inputProps.sourcePath,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\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 repoVisibility = 'private',\n defaultBranch = 'main',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n deleteBranchOnMerge = false,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\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 token: providedToken,\n customProperties,\n subscribe = false,\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 const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.github.repo.${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\n return {\n remoteUrl: newRepo.clone_url,\n repoContentsUrl: `${newRepo.html_url}/blob/${defaultBranch}`,\n };\n },\n });\n\n const commitResult = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.repoVisibility","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.deleteBranchOnMerge","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.sourcePath","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","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AA0CO,SAAS,0BAA0B,OAIvC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAQ,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAE5D,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,gBAAA;AAAA,IACJ,WACE,EAAA,mFAAA;AAAA,cACFC,wBAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,yBAAyBC,uCAAW;AAAA,QACpC,qBAAqBC,mCAAW;AAAA,QAChC,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,yBAAyBC,uCAAW;AAAA,QACpC,gBAAgBC,8BAAW;AAAA,QAC3B,eAAeC,6BAAW;AAAA,QAC1B,sBAAsBC,oCAAW;AAAA,QACjC,sBAAsBC,oCAAW;AAAA,QACjC,qBAAqBC,mCAAW;AAAA,QAChC,kBAAkBC,gCAAW;AAAA,QAC7B,eAAeC,6BAAW;AAAA,QAC1B,gBAAgBC,8BAAW;AAAA,QAC3B,kBAAkBC,gCAAW;AAAA,QAC7B,kBAAkBC,gCAAW;AAAA,QAC7B,wBAAwBC,sCAAW;AAAA,QACnC,0BAA0BC,wCAAW;AAAA,QACrC,kBAAkBC,gCAAW;AAAA,QAC7B,gBAAgBC,8BAAW;AAAA,QAC3B,mBAAmBC,iCAAW;AAAA,QAC9B,YAAYC,0BAAW;AAAA,QACvB,eAAeC,6BAAW;AAA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AAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
@@ -14,35 +14,21 @@ function createGithubActionsDispatchAction(options) {
14
14
  examples: githubActionsDispatch_examples.examples,
15
15
  schema: {
16
16
  input: {
17
- type: "object",
18
- required: ["repoUrl", "workflowId", "branchOrTagName"],
19
- properties: {
20
- repoUrl: {
21
- title: "Repository Location",
22
- description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
23
- type: "string"
24
- },
25
- workflowId: {
26
- title: "Workflow ID",
27
- description: "The GitHub Action Workflow filename",
28
- type: "string"
29
- },
30
- branchOrTagName: {
31
- title: "Branch or Tag name",
32
- description: "The git branch or tag name used to dispatch the workflow",
33
- type: "string"
34
- },
35
- workflowInputs: {
36
- title: "Workflow Inputs",
37
- description: "Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ",
38
- type: "object"
39
- },
40
- token: {
41
- title: "Authentication Token",
42
- type: "string",
43
- description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
44
- }
45
- }
17
+ repoUrl: (z) => z.string({
18
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username"
19
+ }),
20
+ workflowId: (z) => z.string({
21
+ description: "The GitHub Action Workflow filename"
22
+ }),
23
+ branchOrTagName: (z) => z.string({
24
+ description: "The git branch or tag name used to dispatch the workflow"
25
+ }),
26
+ workflowInputs: (z) => z.record(z.string(), {
27
+ description: "Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10."
28
+ }).optional(),
29
+ token: (z) => z.string({
30
+ description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
31
+ }).optional()
46
32
  }
47
33
  },
48
34
  async handler(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"githubActionsDispatch.cjs.js","sources":["../../src/actions/githubActionsDispatch.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 ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n workflowId: string;\n branchOrTagName: string;\n workflowInputs?: { [key: string]: string };\n token?: string;\n }>({\n id: 'github:actions:dispatch',\n description:\n 'Dispatches a GitHub Action workflow for a given branch or tag',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'workflowId', 'branchOrTagName'],\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 workflowId: {\n title: 'Workflow ID',\n description: 'The GitHub Action Workflow filename',\n type: 'string',\n },\n branchOrTagName: {\n title: 'Branch or Tag name',\n description:\n 'The git branch or tag name used to dispatch the workflow',\n type: 'string',\n },\n workflowInputs: {\n title: 'Workflow Inputs',\n description:\n 'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ',\n type: 'object',\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 workflowId,\n branchOrTagName,\n workflowInputs,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(\n `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`,\n );\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 host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.workflow.dispatch.${owner}.${repo}.${workflowId}`,\n fn: async () => {\n await client.rest.actions.createWorkflowDispatch({\n owner,\n repo,\n workflow_id: workflowId,\n ref: branchOrTagName,\n inputs: workflowInputs,\n });\n\n ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,kCAAkC,OAG/C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WACE,EAAA,+DAAA;AAAA,cACFC,uCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,YAAA,EAAc,iBAAiB,CAAA;AAAA,QACrD,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAAO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AA,OACV,CAAA;AAED,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,KAAK,CAA4B,yBAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,IAAI,UAAU,CAAA,CAAA;AAAA,QAC5D,IAAI,YAAY;AACd,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,sBAAuB,CAAA;AAAA,YAC/C,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,UAAA;AAAA,YACb,GAAK,EAAA,eAAA;AAAA,YACL,MAAQ,EAAA;AAAA,WACT,CAAA;AAED,UAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAA0B,wBAAA,CAAA,CAAA;AAAA;AAClE,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubActionsDispatch.cjs.js","sources":["../../src/actions/githubActionsDispatch.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 ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:actions:dispatch',\n description:\n 'Dispatches a GitHub Action workflow for a given branch or tag',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n workflowId: z =>\n z.string({\n description: 'The GitHub Action Workflow filename',\n }),\n branchOrTagName: z =>\n z.string({\n description:\n 'The git branch or tag name used to dispatch the workflow',\n }),\n workflowInputs: z =>\n z\n .record(z.string(), {\n description:\n 'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n workflowId,\n branchOrTagName,\n workflowInputs,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(\n `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`,\n );\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 host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.workflow.dispatch.${owner}.${repo}.${workflowId}`,\n fn: async () => {\n await client.rest.actions.createWorkflowDispatch({\n owner,\n repo,\n workflow_id: workflowId,\n ref: branchOrTagName,\n inputs: workflowInputs,\n });\n\n ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,kCAAkC,OAG/C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yB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AAA;AAAA;AAGrE,MAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,QAC7C,YAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,mBAAqB,EAAA,yBAAA;AAAA,QACrB,KAAO,EAAA;AAAA,OACR,CAAA;AACD,MAAM,MAAA,MAAA,GAAS,IAAIC,eAAQ,CAAA;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAI,CAAA;AAAA,OACV,CAAA;AAED,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,KAAK,CAA4B,yBAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,IAAI,UAAU,CAAA,CAAA;AAAA,QAC5D,IAAI,YAAY;AACd,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,sBAAuB,CAAA;AAAA,YAC/C,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,UAAA;AAAA,YACb,GAAK,EAAA,eAAA;AAAA,YACL,MAAQ,EAAA;AAAA,WACT,CAAA;AAED,UAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAA0B,wBAAA,CAAA,CAAA;AAAA;AAClE,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
@@ -14,36 +14,21 @@ function createGithubAutolinksAction(options) {
14
14
  examples: githubAutolinks_examples.examples,
15
15
  schema: {
16
16
  input: {
17
- type: "object",
18
- required: ["repoUrl", "keyPrefix", "urlTemplate"],
19
- properties: {
20
- repoUrl: {
21
- title: "Repository Location",
22
- description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
23
- type: "string"
24
- },
25
- keyPrefix: {
26
- title: "Key Prefix",
27
- description: "This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.",
28
- type: "string"
29
- },
30
- urlTemplate: {
31
- title: "URL Template",
32
- description: "The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.",
33
- type: "string"
34
- },
35
- isAlphanumeric: {
36
- title: "Alphanumeric",
37
- description: "Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`",
38
- type: "boolean",
39
- default: true
40
- },
41
- token: {
42
- title: "Authentication Token",
43
- type: "string",
44
- description: "The token to use for authorization to GitHub"
45
- }
46
- }
17
+ repoUrl: (z) => z.string({
18
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username"
19
+ }),
20
+ keyPrefix: (z) => z.string({
21
+ description: "This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit."
22
+ }),
23
+ urlTemplate: (z) => z.string({
24
+ description: "The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric."
25
+ }),
26
+ isAlphanumeric: (z) => z.boolean({
27
+ description: "Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`"
28
+ }).default(true).optional(),
29
+ token: (z) => z.string({
30
+ description: "The token to use for authorization to GitHub"
31
+ }).optional()
47
32
  }
48
33
  },
49
34
  async handler(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"githubAutolinks.cjs.js","sources":["../../src/actions/githubAutolinks.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 ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { examples } from './githubAutolinks.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Create an autolink reference for a repository\n * @public\n */\nexport function createGithubAutolinksAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n keyPrefix: string;\n urlTemplate: string;\n isAlphanumeric?: boolean;\n token?: string;\n }>({\n id: 'github:autolinks:create',\n description: 'Create an autolink reference for a repository',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'keyPrefix', 'urlTemplate'],\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 keyPrefix: {\n title: 'Key Prefix',\n description:\n 'This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.',\n type: 'string',\n },\n urlTemplate: {\n title: 'URL Template',\n description:\n 'The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.',\n type: 'string',\n },\n isAlphanumeric: {\n title: 'Alphanumeric',\n description:\n 'Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`',\n type: 'boolean',\n default: true,\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } =\n ctx.input;\n\n ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);\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 host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.auto.link.${owner}.${repo}`,\n fn: async () => {\n await client.rest.repos.createAutolink({\n owner,\n repo,\n key_prefix: keyPrefix,\n url_template: urlTemplate,\n is_alphanumeric: isAlphanumeric,\n });\n\n ctx.logger.info(`Autolink reference created successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,4BAA4B,OAGzC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,+CAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,WAAA,EAAa,aAAa,CAAA;AAAA,QAChD,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,YAAA;AAAA,YACP,WACE,EAAA,4HAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,cAAA;AAAA,YACP,WACE,EAAA,uIAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,cAAgB,EAAA;A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AAA;AAAA,YACZ,YAAc,EAAA,WAAA;AAAA,YACd,eAAiB,EAAA;AAAA,WAClB,CAAA;AAED,UAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAyC,uCAAA,CAAA,CAAA;AAAA;AAC3D,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubAutolinks.cjs.js","sources":["../../src/actions/githubAutolinks.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 ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { examples } from './githubAutolinks.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Create an autolink reference for a repository\n * @public\n */\nexport function createGithubAutolinksAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:autolinks:create',\n description: 'Create an autolink reference for a repository',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n keyPrefix: z =>\n z.string({\n description:\n 'This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.',\n }),\n urlTemplate: z =>\n z.string({\n description:\n 'The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.',\n }),\n isAlphanumeric: z =>\n z\n .boolean({\n description:\n 'Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`',\n })\n .default(true)\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } =\n ctx.input;\n\n ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);\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 host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.auto.link.${owner}.${repo}`,\n fn: async () => {\n await client.rest.repos.createAutolink({\n owner,\n repo,\n key_prefix: keyPrefix,\n url_template: urlTemplate,\n is_alphanumeric: isAlphanumeric,\n });\n\n ctx.logger.info(`Autolink reference created successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,4BAA4B,OAGzC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,+CAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,CACP,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH,CAAA;AAAA,QACH,SAAA,EAAW,C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AA,EAAoB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACtC,IAAI,YAAY;AACd,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,cAAe,CAAA;AAAA,YACrC,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAY,EAAA,SAAA;AAAA,YACZ,YAAc,EAAA,WAAA;AAAA,YACd,eAAiB,EAAA;AAAA,WAClB,CAAA;AAED,UAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAyC,uCAAA,CAAA,CAAA;AAAA;AAC3D,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
@@ -16,29 +16,21 @@ function createGithubBranchProtectionAction(options) {
16
16
  examples: githubBranchProtection_examples.examples,
17
17
  schema: {
18
18
  input: {
19
- type: "object",
20
- required: ["repoUrl"],
21
- properties: {
22
- repoUrl: inputProperties.repoUrl,
23
- branch: {
24
- title: "Branch name",
25
- description: `The branch to protect. Defaults to the repository's default branch`,
26
- type: "string"
27
- },
28
- enforceAdmins: inputProperties.protectEnforceAdmins,
29
- requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
30
- requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
31
- dismissStaleReviews: inputProperties.dismissStaleReviews,
32
- bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
33
- restrictions: inputProperties.restrictions,
34
- requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
35
- requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
36
- requiredConversationResolution: inputProperties.requiredConversationResolution,
37
- requireLastPushApproval: inputProperties.requireLastPushApproval,
38
- requiredCommitSigning: inputProperties.requiredCommitSigning,
39
- requiredLinearHistory: inputProperties.requiredLinearHistory,
40
- token: inputProperties.token
41
- }
19
+ repoUrl: inputProperties.repoUrl,
20
+ branch: inputProperties.branch,
21
+ enforceAdmins: inputProperties.protectEnforceAdmins,
22
+ requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
23
+ requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
24
+ dismissStaleReviews: inputProperties.dismissStaleReviews,
25
+ bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
26
+ restrictions: inputProperties.restrictions,
27
+ requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
28
+ requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
29
+ requiredConversationResolution: inputProperties.requiredConversationResolution,
30
+ requireLastPushApproval: inputProperties.requireLastPushApproval,
31
+ requiredCommitSigning: inputProperties.requiredCommitSigning,
32
+ requiredLinearHistory: inputProperties.requiredLinearHistory,
33
+ token: inputProperties.token
42
34
  }
43
35
  },
44
36
  async handler(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"githubBranchProtection.cjs.js","sources":["../../src/actions/githubBranchProtection.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 createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { examples } from './githubBranchProtection.examples';\nimport * as inputProps from './inputProperties';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport { enableBranchProtectionOnDefaultRepoBranch } from './gitHelpers';\n\n/**\n * Creates an `github:branch-protection:create` Scaffolder action that configured Branch Protection in a Github Repository.\n *\n * @public\n */\nexport function createGithubBranchProtectionAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n branch?: string;\n enforceAdmins?: boolean;\n requiredApprovingReviewCount?: number;\n requireCodeOwnerReviews?: boolean;\n dismissStaleReviews?: boolean;\n bypassPullRequestAllowances?:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined;\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 requireLastPushApproval?: boolean;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n token?: string;\n }>({\n id: 'github:branch-protection:create',\n description: 'Configures Branch Protection',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: inputProps.repoUrl,\n branch: {\n title: 'Branch name',\n description: `The branch to protect. Defaults to the repository's default branch`,\n type: 'string',\n },\n enforceAdmins: inputProps.protectEnforceAdmins,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n token: inputProps.token,\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch,\n enforceAdmins = true,\n requiredApprovingReviewCount = 1,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\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 defaultBranch = await ctx.checkpoint({\n key: `read.default.branch.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.default_branch;\n },\n });\n\n await ctx.checkpoint({\n key: `enable.branch.protection.${owner}.${repo}`,\n fn: async () => {\n await enableBranchProtectionOnDefaultRepoBranch({\n repoName: repo,\n client,\n owner,\n logger: ctx.logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n defaultBranch: branch ?? defaultBranch,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n });\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.protectEnforceAdmins","inputProps.requiredApprovingReviewCount","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.bypassPullRequestAllowances","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.token","parseRepoUrl","InputError","getOctokitOptions","Octokit","enableBranchProtectionOnDefaultRepoBranch"],"mappings":";;;;;;;;;;AAiCO,SAAS,mCAAmC,OAEhD,EAAA;AACD,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAEzB,EAAA,OAAOA,yCA4BJ,CAAA;AAAA,IACD,EAAI,EAAA,iCAAA;AAA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A;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,eAAe,MAAU,IAAA,aAAA;AAAA,YACzB,aAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA;AACH,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubBranchProtection.cjs.js","sources":["../../src/actions/githubBranchProtection.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 createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { examples } from './githubBranchProtection.examples';\nimport * as inputProps from './inputProperties';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport { enableBranchProtectionOnDefaultRepoBranch } from './gitHelpers';\n\n/**\n * Creates an `github:branch-protection:create` Scaffolder action that configured Branch Protection in a Github Repository.\n *\n * @public\n */\nexport function createGithubBranchProtectionAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'github:branch-protection:create',\n description: 'Configures Branch Protection',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n branch: inputProps.branch,\n enforceAdmins: inputProps.protectEnforceAdmins,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n token: inputProps.token,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch,\n enforceAdmins = true,\n requiredApprovingReviewCount = 1,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\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 defaultBranch = await ctx.checkpoint({\n key: `read.default.branch.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.default_branch;\n },\n });\n\n await ctx.checkpoint({\n key: `enable.branch.protection.${owner}.${repo}`,\n fn: async () => {\n await enableBranchProtectionOnDefaultRepoBranch({\n repoName: repo,\n client,\n owner,\n logger: ctx.logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n defaultBranch: branch ?? defaultBranch,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n });\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.branch","inputProps.protectEnforceAdmins","inputProps.requiredApprovingReviewCount","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.bypassPullRequestAllowances","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.token","parseRepoUrl","InputError","getOctokitOptions","Octokit","enableBranchProtectionOnDefaultRepoBranch"],"mappings":";;;;;;;;;;AAiCO,SAAS,mCAAmC,OAEhD,EAAA;AACD,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAEzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,iCAAA;AAAA,IACJ,WAAa,EAAA,8BAAA;AAAA,cACbC,wCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,QAAQC,sBAAW;AAAA,QACnB,eAAeC,oCAAW;AAAA,QAC1B,8BAA8BC,4CAAW;AAAA,QACzC,yBAAyBC,uCAAW;AAAA,QACpC,qBAAqBC,mCAAW;AAAA,QAChC,6BAA6BC,2CAAW;AAAA,QACxC,cAAcC,4BAAW;AAAA,QACzB,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,yBAAyBC,uCAAW;AAAA,QACpC,uBAAuBC,qCAAW;AAAA,QAClC,uBAAuBC,qCAAW;AAAA,QAClC,OAAOC;AAAW;AACpB,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAM,MAAA;AAAA,QACJ,OAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAgB,GAAA,IAAA;AAAA,QAChB,4BAA+B,GAAA,CAAA;AAAA,QAC/B,uBAA0B,GAAA,KAAA;AAAA,QAC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