@backstage/plugin-scaffolder-backend-module-github 0.8.3-next.1 → 0.9.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.9.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - c8aa210: Updating import for the `scaffolderActionsExtensionPoint` to be the main export
8
+ - Updated dependencies
9
+ - @backstage/integration@1.18.1-next.0
10
+ - @backstage/plugin-scaffolder-node@0.12.0-next.0
11
+ - @backstage/backend-plugin-api@1.4.3
12
+ - @backstage/catalog-model@1.7.5
13
+ - @backstage/config@1.3.3
14
+ - @backstage/errors@1.2.7
15
+ - @backstage/types@1.2.2
16
+ - @backstage/plugin-catalog-node@1.19.0
17
+
18
+ ## 0.9.0
19
+
20
+ ### Minor Changes
21
+
22
+ - f0f06b4: Adding a new scaffolder action `github:issues:create` following the reference of `github:issues:label` with `dryRun` testing possibility
23
+
24
+ It can be used like this
25
+
26
+ ```
27
+ steps:
28
+ - id: create-simple-issue
29
+ name: Create Simple Issue
30
+ action: github:issues:create
31
+ input:
32
+ repoUrl: ${{ parameters.repoUrl }}
33
+ title: "[${{ parameters.projectName }}] Simple Bug Report"
34
+ body: |
35
+ ## Bug Description
36
+ This is a simple bug report created by the scaffolder template.
37
+
38
+ ### Steps to Reproduce
39
+ 1. Run the application
40
+ 2. Navigate to the main page
41
+ 3. Click on the problematic button
42
+
43
+ ### Expected Behavior
44
+ The button should work correctly.
45
+
46
+ ### Actual Behavior
47
+ The button does not respond to clicks.
48
+ output:
49
+ links:
50
+ - title: Simple Issue
51
+ url: ${{ steps['create-simple-issue'].output.issueUrl }}
52
+ ```
53
+
54
+ ### Patch Changes
55
+
56
+ - aee107b: Add `auto_init` option to `github:repo:create` action to create repository with an initial commit containing a README.md file
57
+
58
+ This initial commit is created by GitHub itself and the commit is signed, so the repository will not be empty after creation.
59
+
60
+ ```diff
61
+ - action: github:repo:create
62
+ id: init-new-repo
63
+ input:
64
+ repoUrl: 'github.com?repo=repo&owner=owner'
65
+ description: This is the description
66
+ visibility: private
67
+ + autoInit: true
68
+
69
+ ```
70
+
71
+ - 6393b78: Add block creations field in github branch protection scaffolder actions
72
+ - Updated dependencies
73
+ - @backstage/plugin-catalog-node@1.19.0
74
+ - @backstage/integration@1.18.0
75
+ - @backstage/types@1.2.2
76
+ - @backstage/backend-plugin-api@1.4.3
77
+ - @backstage/plugin-scaffolder-node@0.11.1
78
+
3
79
  ## 0.8.3-next.1
4
80
 
5
81
  ### Patch Changes
@@ -19,7 +19,8 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
19
19
  enforceAdmins = true,
20
20
  dismissStaleReviews = false,
21
21
  requiredCommitSigning = false,
22
- requiredLinearHistory = false
22
+ requiredLinearHistory = false,
23
+ blockCreations = false
23
24
  }) => {
24
25
  const tryOnce = async () => {
25
26
  try {
@@ -51,7 +52,8 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
51
52
  require_last_push_approval: requireLastPushApproval
52
53
  },
53
54
  required_conversation_resolution: requiredConversationResolution,
54
- required_linear_history: requiredLinearHistory
55
+ required_linear_history: requiredLinearHistory,
56
+ block_creations: blockCreations
55
57
  });
56
58
  if (requiredCommitSigning) {
57
59
  await client.rest.repos.createCommitSignatureProtection({
@@ -1 +1 @@
1
- {"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.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 { assertError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\ntype BranchProtectionOptions = {\n client: Octokit;\n owner: string;\n repoName: string;\n logger: LoggerService;\n requireCodeOwnerReviews: boolean;\n requiredStatusCheckContexts?: string[];\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 requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval: boolean;\n defaultBranch?: string;\n enforceAdmins?: boolean;\n dismissStaleReviews?: boolean;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n};\n\nexport const enableBranchProtectionOnDefaultRepoBranch = async ({\n repoName,\n client,\n owner,\n logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n defaultBranch = 'master',\n enforceAdmins = true,\n dismissStaleReviews = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n}: BranchProtectionOptions): Promise<void> => {\n const tryOnce = async () => {\n try {\n await client.rest.repos.updateBranchProtection({\n mediaType: {\n /**\n * 👇 we need this preview because allowing a custom\n * reviewer count on branch protection is a preview\n * feature\n *\n * More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews\n */\n previews: ['luke-cage-preview'],\n },\n owner,\n repo: repoName,\n branch: defaultBranch,\n required_status_checks: {\n strict: requireBranchesToBeUpToDate,\n contexts: requiredStatusCheckContexts,\n },\n restrictions: restrictions ?? null,\n enforce_admins: enforceAdmins,\n required_pull_request_reviews: {\n required_approving_review_count: requiredApprovingReviewCount,\n require_code_owner_reviews: requireCodeOwnerReviews,\n bypass_pull_request_allowances: bypassPullRequestAllowances,\n dismiss_stale_reviews: dismissStaleReviews,\n require_last_push_approval: requireLastPushApproval,\n },\n required_conversation_resolution: requiredConversationResolution,\n required_linear_history: requiredLinearHistory,\n });\n\n if (requiredCommitSigning) {\n await client.rest.repos.createCommitSignatureProtection({\n owner,\n repo: repoName,\n branch: defaultBranch,\n });\n }\n } catch (e) {\n assertError(e);\n if (\n e.message.includes(\n 'Upgrade to GitHub Pro or make this repository public to enable this feature',\n )\n ) {\n logger.warn(\n 'Branch protection was not enabled as it requires GitHub Pro for private repositories',\n );\n } else {\n throw e;\n }\n }\n };\n\n try {\n await tryOnce();\n } catch (e) {\n if (!e.message.includes('Branch not found')) {\n throw e;\n }\n\n // GitHub has eventual consistency. Fail silently, wait, and try again.\n await new Promise(resolve => setTimeout(resolve, 600));\n await tryOnce();\n }\n};\n\nexport function entityRefToName(name: string): string {\n return name.replace(/^.*[:/]/g, '');\n}\n"],"names":["assertError"],"mappings":";;;;AAgDO,MAAM,4CAA4C,OAAO;AAAA,EAC9D,QAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,uBAAA;AAAA,EACA,2BAAA;AAAA,EACA,4BAAA;AAAA,EACA,YAAA;AAAA,EACA,8BAA8B,EAAC;AAAA,EAC/B,2BAAA,GAA8B,IAAA;AAAA,EAC9B,8BAAA,GAAiC,KAAA;AAAA,EACjC,uBAAA,GAA0B,KAAA;AAAA,EAC1B,aAAA,GAAgB,QAAA;AAAA,EAChB,aAAA,GAAgB,IAAA;AAAA,EAChB,mBAAA,GAAsB,KAAA;AAAA,EACtB,qBAAA,GAAwB,KAAA;AAAA,EACxB,qBAAA,GAAwB;AAC1B,CAAA,KAA8C;AAC5C,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,sBAAA,CAAuB;AAAA,QAC7C,SAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,GAAG,CAAC,CAAA;AACrD,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB;AACF;AAEO,SAAS,gBAAgB,IAAA,EAAsB;AACpD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AACpC;;;;;"}
1
+ {"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.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 { assertError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\ntype BranchProtectionOptions = {\n client: Octokit;\n owner: string;\n repoName: string;\n logger: LoggerService;\n requireCodeOwnerReviews: boolean;\n requiredStatusCheckContexts?: string[];\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 requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval: boolean;\n defaultBranch?: string;\n enforceAdmins?: boolean;\n dismissStaleReviews?: boolean;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n blockCreations?: boolean;\n};\n\nexport const enableBranchProtectionOnDefaultRepoBranch = async ({\n repoName,\n client,\n owner,\n logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n defaultBranch = 'master',\n enforceAdmins = true,\n dismissStaleReviews = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n blockCreations = false,\n}: BranchProtectionOptions): Promise<void> => {\n const tryOnce = async () => {\n try {\n await client.rest.repos.updateBranchProtection({\n mediaType: {\n /**\n * 👇 we need this preview because allowing a custom\n * reviewer count on branch protection is a preview\n * feature\n *\n * More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews\n */\n previews: ['luke-cage-preview'],\n },\n owner,\n repo: repoName,\n branch: defaultBranch,\n required_status_checks: {\n strict: requireBranchesToBeUpToDate,\n contexts: requiredStatusCheckContexts,\n },\n restrictions: restrictions ?? null,\n enforce_admins: enforceAdmins,\n required_pull_request_reviews: {\n required_approving_review_count: requiredApprovingReviewCount,\n require_code_owner_reviews: requireCodeOwnerReviews,\n bypass_pull_request_allowances: bypassPullRequestAllowances,\n dismiss_stale_reviews: dismissStaleReviews,\n require_last_push_approval: requireLastPushApproval,\n },\n required_conversation_resolution: requiredConversationResolution,\n required_linear_history: requiredLinearHistory,\n block_creations: blockCreations,\n });\n\n if (requiredCommitSigning) {\n await client.rest.repos.createCommitSignatureProtection({\n owner,\n repo: repoName,\n branch: defaultBranch,\n });\n }\n } catch (e) {\n assertError(e);\n if (\n e.message.includes(\n 'Upgrade to GitHub Pro or make this repository public to enable this feature',\n )\n ) {\n logger.warn(\n 'Branch protection was not enabled as it requires GitHub Pro for private repositories',\n );\n } else {\n throw e;\n }\n }\n };\n\n try {\n await tryOnce();\n } catch (e) {\n if (!e.message.includes('Branch not found')) {\n throw e;\n }\n\n // GitHub has eventual consistency. Fail silently, wait, and try again.\n await new Promise(resolve => setTimeout(resolve, 600));\n await tryOnce();\n }\n};\n\nexport function entityRefToName(name: string): string {\n return name.replace(/^.*[:/]/g, '');\n}\n"],"names":["assertError"],"mappings":";;;;AAiDO,MAAM,4CA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ACzB,eAAA,EAAiB;AAAA,OAClB,CAAA;AAED,MAAA,IAAI,qBAAA,EAAuB;AACzB,QAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,+BAAA,CAAgC;AAAA,UACtD,KAAA;AAAA,UACA,IAAA,EAAM,QAAA;AAAA,UACN,MAAA,EAAQ;AAAA,SACT,CAAA;AAAA,MACH;AAAA,IACF,SAAS,CAAA,EAAG;AACV,MAAAA,kBAAA,CAAY,CAAC,CAAA;AACb,MAAA,IACE,EAAE,OAAA,CAAQ,QAAA;AAAA,QACR;AAAA,OACF,EACA;AACA,QAAA,MAAA,CAAO,IAAA;AAAA,UACL;AAAA,SACF;AAAA,MACF,CAAA,MAAO;AACL,QAAA,MAAM,CAAA;AAAA,MACR;AAAA,IACF;AAAA,EACF,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAA,CAAS,kBAAkB,CAAA,EAAG;AAC3C,MAAA,MAAM,CAAA;AAAA,IACR;AAGA,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,GAAG,CAAC,CAAA;AACrD,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB;AACF;AAEO,SAAS,gBAAgB,IAAA,EAAsB;AACpD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AACpC;;;;;"}
@@ -30,6 +30,7 @@ function createGithubBranchProtectionAction(options) {
30
30
  requireLastPushApproval: inputProperties.requireLastPushApproval,
31
31
  requiredCommitSigning: inputProperties.requiredCommitSigning,
32
32
  requiredLinearHistory: inputProperties.requiredLinearHistory,
33
+ blockCreations: inputProperties.blockCreations,
33
34
  token: inputProperties.token
34
35
  }
35
36
  },
@@ -49,6 +50,7 @@ function createGithubBranchProtectionAction(options) {
49
50
  requireLastPushApproval = false,
50
51
  requiredCommitSigning = false,
51
52
  requiredLinearHistory = false,
53
+ blockCreations,
52
54
  token: providedToken
53
55
  } = ctx.input;
54
56
  const { host, owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
@@ -96,7 +98,8 @@ function createGithubBranchProtectionAction(options) {
96
98
  enforceAdmins,
97
99
  dismissStaleReviews,
98
100
  requiredCommitSigning,
99
- requiredLinearHistory
101
+ requiredLinearHistory,
102
+ blockCreations
100
103
  });
101
104
  }
102
105
  });
@@ -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 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,OAAA,EAEhD;AACD,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,iCAAA;AAAA,IACJ,WAAA,EAAa,8BAAA;AAAA,cACbC,wCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;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,GAAA,EAAK;AACjB,MAAA,MAAM;AAAA,QACJ,OAA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D,UAAA,OAAO,WAAW,IAAA,CAAK,cAAA;AAAA,QACzB;AAAA,OACD,CAAA;AAED,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC9C,IAAI,YAAY;AACd,UAAA,MAAMC,oDAAA,CAA0C;AAAA,YAC9C,QAAA,EAAU,IAAA;AAAA,YACV,MAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAQ,GAAA,CAAI,MAAA;AAAA,YACZ,uBAAA;AAAA,YACA,2BAAA;AAAA,YACA,4BAAA;AAAA,YACA,YAAA;AAAA,YACA,2BAAA;AAAA,YACA,2BAAA;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,eAAe,MAAA,IAAU,aAAA;AAAA,YACzB,aAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,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 blockCreations: inputProps.blockCreations,\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 blockCreations,\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 blockCreations,\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.blockCreations","inputProps.token","parseRepoUrl","InputError","getOctokitOptions","Octokit","enableBranchProtectionOnDefaultRepoBranch"],"mappings":";;;;;;;;;;AAiCO,SAAS,mCAAmC,OAAA,EAEhD;AACD,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,iCAAA;AAAA,IACJ,WAAA,EAAa,8BAAA;AAAA,cACbC,wCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,QAAQC,sBAAW;AAAA,QACnB,eAAeC,oCAAW;AAAA,QAC1B,8BAA8BC,4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AA,QACA;AAAA,OACD,CAAA;AACD,MAAA,MAAM,MAAA,GAAS,IAAIC,eAAA,CAAQ;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,MAAM,aAAA,GAAgB,MAAM,GAAA,CAAI,UAAA,CAAW;AAAA,QACzC,GAAA,EAAK,CAAA,oBAAA,EAAuB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACzC,IAAI,YAAY;AACd,UAAA,MAAM,UAAA,GAAa,MAAM,MAAA,CAAO,IAAA,CAAK,MAAM,GAAA,CAAI;AAAA,YAC7C,KAAA;AAAA,YACA;AAAA,WACD,CAAA;AACD,UAAA,OAAO,WAAW,IAAA,CAAK,cAAA;AAAA,QACzB;AAAA,OACD,CAAA;AAED,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC9C,IAAI,YAAY;AACd,UAAA,MAAMC,oDAAA,CAA0C;AAAA,YAC9C,QAAA,EAAU,IAAA;AAAA,YACV,MAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAQ,GAAA,CAAI,MAAA;AAAA,YACZ,uBAAA;AAAA,YACA,2BAAA;AAAA,YACA,4BAAA;AAAA,YACA,YAAA;AAAA,YACA,2BAAA;AAAA,YACA,2BAAA;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,eAAe,MAAA,IAAU,aAAA;AAAA,YACzB,aAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,122 @@
1
+ 'use strict';
2
+
3
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
+ var errors = require('@backstage/errors');
5
+ var octokit = require('octokit');
6
+ var util = require('../util.cjs.js');
7
+ var githubIssuesCreate_examples = require('./githubIssuesCreate.examples.cjs.js');
8
+
9
+ function createGithubIssuesCreateAction(options) {
10
+ const { integrations, githubCredentialsProvider } = options;
11
+ return pluginScaffolderNode.createTemplateAction({
12
+ id: "github:issues:create",
13
+ description: "Creates an issue on GitHub.",
14
+ examples: githubIssuesCreate_examples.examples,
15
+ supportsDryRun: true,
16
+ schema: {
17
+ input: {
18
+ repoUrl: (z) => z.string({
19
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username"
20
+ }),
21
+ title: (z) => z.string({
22
+ description: "The title of the issue"
23
+ }),
24
+ body: (z) => z.string({
25
+ description: "The contents of the issue"
26
+ }).optional(),
27
+ assignees: (z) => z.array(z.string(), {
28
+ description: "Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise."
29
+ }).optional(),
30
+ milestone: (z) => z.union([z.string(), z.number()], {
31
+ description: "The number of the milestone to associate this issue with. NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise."
32
+ }).optional(),
33
+ labels: (z) => z.array(z.string(), {
34
+ description: "Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise."
35
+ }).optional(),
36
+ token: (z) => z.string({
37
+ description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
38
+ }).optional()
39
+ },
40
+ output: {
41
+ issueUrl: (z) => z.string({
42
+ description: "The URL of the created issue"
43
+ }),
44
+ issueNumber: (z) => z.number({
45
+ description: "The number of the created issue"
46
+ })
47
+ }
48
+ },
49
+ async handler(ctx) {
50
+ const {
51
+ repoUrl,
52
+ title,
53
+ body,
54
+ assignees,
55
+ milestone,
56
+ labels,
57
+ token: providedToken
58
+ } = ctx.input;
59
+ const { host, owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
60
+ ctx.logger.info(`Creating issue "${title}" on repo ${repo}`);
61
+ if (!owner) {
62
+ throw new errors.InputError("Invalid repository owner provided in repoUrl");
63
+ }
64
+ const octokitOptions = await util.getOctokitOptions({
65
+ integrations,
66
+ credentialsProvider: githubCredentialsProvider,
67
+ host,
68
+ owner,
69
+ repo,
70
+ token: providedToken
71
+ });
72
+ const client = new octokit.Octokit({
73
+ ...octokitOptions,
74
+ log: ctx.logger
75
+ });
76
+ if (ctx.isDryRun) {
77
+ ctx.logger.info(`Performing dry run of creating issue "${title}"`);
78
+ ctx.output("issueUrl", `https://github.com/${owner}/${repo}/issues/42`);
79
+ ctx.output("issueNumber", 42);
80
+ ctx.logger.info(`Dry run complete`);
81
+ return;
82
+ }
83
+ try {
84
+ const issue = await ctx.checkpoint({
85
+ key: `github.issues.create.${owner}.${repo}.${title}`,
86
+ fn: async () => {
87
+ const response = await client.rest.issues.create({
88
+ owner,
89
+ repo,
90
+ title,
91
+ body,
92
+ assignees,
93
+ milestone,
94
+ labels
95
+ });
96
+ return {
97
+ html_url: response.data.html_url,
98
+ number: response.data.number
99
+ };
100
+ }
101
+ });
102
+ if (!issue) {
103
+ throw new Error("Failed to create issue");
104
+ }
105
+ ctx.output("issueUrl", issue.html_url);
106
+ ctx.output("issueNumber", issue.number);
107
+ ctx.logger.info(
108
+ `Successfully created issue #${issue.number}: ${issue.html_url}`
109
+ );
110
+ } catch (e) {
111
+ errors.assertError(e);
112
+ ctx.logger.warn(
113
+ `Failed: creating issue '${title}' on repo: '${repo}', ${e.message}`
114
+ );
115
+ throw e;
116
+ }
117
+ }
118
+ });
119
+ }
120
+
121
+ exports.createGithubIssuesCreateAction = createGithubIssuesCreateAction;
122
+ //# sourceMappingURL=githubIssuesCreate.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"githubIssuesCreate.cjs.js","sources":["../../src/actions/githubIssuesCreate.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 { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesCreate.examples';\n\n/**\n * Creates an issue on GitHub\n * @public\n */\nexport function createGithubIssuesCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:issues:create',\n description: 'Creates an issue on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n title: z =>\n z.string({\n description: 'The title of the issue',\n }),\n body: z =>\n z\n .string({\n description: 'The contents of the issue',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise.',\n })\n .optional(),\n milestone: z =>\n z\n .union([z.string(), z.number()], {\n description:\n 'The number of the milestone to associate this issue with. NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise.',\n })\n .optional(),\n labels: z =>\n z\n .array(z.string(), {\n description:\n 'Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise.',\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 output: {\n issueUrl: z =>\n z.string({\n description: 'The URL of the created issue',\n }),\n issueNumber: z =>\n z.number({\n description: 'The number of the created issue',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n body,\n assignees,\n milestone,\n labels,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Creating issue \"${title}\" on repo ${repo}`);\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\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating issue \"${title}\"`);\n ctx.output('issueUrl', `https://github.com/${owner}/${repo}/issues/42`);\n ctx.output('issueNumber', 42);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const issue = await ctx.checkpoint({\n key: `github.issues.create.${owner}.${repo}.${title}`,\n fn: async () => {\n const response = await client.rest.issues.create({\n owner,\n repo,\n title,\n body,\n assignees,\n milestone,\n labels,\n });\n\n return {\n html_url: response.data.html_url,\n number: response.data.number,\n };\n },\n });\n\n if (!issue) {\n throw new Error('Failed to create issue');\n }\n\n ctx.output('issueUrl', issue.html_url);\n ctx.output('issueNumber', issue.number);\n\n ctx.logger.info(\n `Successfully created issue #${issue.number}: ${issue.html_url}`,\n );\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: creating issue '${title}' on repo: '${repo}', ${e.message}`,\n );\n throw e;\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,+BAA+B,OAAA,EAG5C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAA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AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopNamespaceCompat(e) {
6
+ if (e && typeof e === 'object' && 'default' in e) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var yaml__namespace = /*#__PURE__*/_interopNamespaceCompat(yaml);
24
+
25
+ const examples = [
26
+ {
27
+ description: "Create a simple issue",
28
+ example: yaml__namespace.stringify({
29
+ steps: [
30
+ {
31
+ action: "github:issues:create",
32
+ name: "Create issue",
33
+ input: {
34
+ repoUrl: "github.com?repo=repo&owner=owner",
35
+ title: "Bug report",
36
+ body: "Found a bug that needs to be fixed"
37
+ }
38
+ }
39
+ ]
40
+ })
41
+ },
42
+ {
43
+ description: "Create an issue with labels and assignees",
44
+ example: yaml__namespace.stringify({
45
+ steps: [
46
+ {
47
+ action: "github:issues:create",
48
+ name: "Create issue with metadata",
49
+ input: {
50
+ repoUrl: "github.com?repo=repo&owner=owner",
51
+ title: "Feature request",
52
+ body: "This is a new feature request",
53
+ labels: ["enhancement", "needs-review"],
54
+ assignees: ["octocat"],
55
+ milestone: 1
56
+ }
57
+ }
58
+ ]
59
+ })
60
+ },
61
+ {
62
+ description: "Create an issue with specific token",
63
+ example: yaml__namespace.stringify({
64
+ steps: [
65
+ {
66
+ action: "github:issues:create",
67
+ name: "Create issue with token",
68
+ input: {
69
+ repoUrl: "github.com?repo=repo&owner=owner",
70
+ title: "Documentation update",
71
+ body: "Update the documentation for the new API",
72
+ labels: ["documentation"],
73
+ token: "gph_YourGitHubToken"
74
+ }
75
+ }
76
+ ]
77
+ })
78
+ }
79
+ ];
80
+
81
+ exports.examples = examples;
82
+ //# sourceMappingURL=githubIssuesCreate.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"githubIssuesCreate.examples.cjs.js","sources":["../../src/actions/githubIssuesCreate.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 * as yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a simple issue',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:create',\n name: 'Create issue',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n title: 'Bug report',\n body: 'Found a bug that needs to be fixed',\n },\n },\n ],\n }),\n },\n {\n description: 'Create an issue with labels and assignees',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:create',\n name: 'Create issue with metadata',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n title: 'Feature request',\n body: 'This is a new feature request',\n labels: ['enhancement', 'needs-review'],\n assignees: ['octocat'],\n milestone: 1,\n },\n },\n ],\n }),\n },\n {\n description: 'Create an issue with specific token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:issues:create',\n name: 'Create issue with token',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n title: 'Documentation update',\n body: 'Update the documentation for the new API',\n labels: ['documentation'],\n token: 'gph_YourGitHubToken',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,QAAA,GAA8B;A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Properties.requiredCommitSigning,
50
50
  requiredLinearHistory: inputProperties.requiredLinearHistory,
51
51
  customProperties: inputProperties.customProperties,
52
- subscribe: inputProperties.subscribe
52
+ subscribe: inputProperties.subscribe,
53
+ autoInit: inputProperties.autoInit
53
54
  },
54
55
  output: {
55
56
  remoteUrl: outputProperties.remoteUrl,
@@ -81,7 +82,8 @@ function createGithubRepoCreateAction(options) {
81
82
  oidcCustomization,
82
83
  customProperties,
83
84
  subscribe,
84
- token: providedToken
85
+ token: providedToken,
86
+ autoInit = void 0
85
87
  } = ctx.input;
86
88
  const { host, owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
87
89
  if (!owner) {
@@ -128,7 +130,8 @@ function createGithubRepoCreateAction(options) {
128
130
  oidcCustomization,
129
131
  customProperties,
130
132
  subscribe,
131
- ctx.logger
133
+ ctx.logger,
134
+ autoInit
132
135
  );
133
136
  return newRepo.clone_url;
134
137
  }
@@ -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 id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n repoVisibility: inputProps.repoVisibility,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n repoVisibility = 'private',\n deleteBranchOnMerge = false,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const remoteUrl = await ctx.checkpoint({\n key: `create.repo.and.topics.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n return newRepo.clone_url;\n },\n });\n\n ctx.output('remoteUrl', remoteUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.requireCodeOwnerReviews","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.repoVisibility","inputProps.deleteBranchOnMerge","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings":";;;;;;;;;;;AAqCO,SAAS,6BAA6B,OAAA,EAG1C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,oBAAA;AAAA,IACJ,WAAA,EAAa,8BAAA;AAAA,cACbC,kCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,yBAAyBC,uCAAW;AAAA,QACpC,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,gBAAgBC,8BAAW;AAAA,QAC3B,qBAAqBC,mCAAW;AAAA,QAChC,kBAAkBC,gCAAW;AAAA,QAC7B,kBAAkBC,gCAAW;AAAA,QAC7B,wBAAwBC,sCAAW;AAAA,QACnC,0BAA0BC,wCAAW;AAAA,QACrC,kBAAkBC,gCAAW;AAAA,QAC7B,gBAAgBC,8BAAW;AAAA,QAC3B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AAA;AACH;;;;"}
1
+ {"version":3,"file":"githubRepoCreate.cjs.js","sources":["../../src/actions/githubRepoCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { createGithubRepoWithCollaboratorsAndTopics } from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './githubRepoCreate.examples';\n\n/**\n * Creates a new action that initializes a git repository\n *\n * @public\n */\nexport function createGithubRepoCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:repo:create',\n description: 'Creates a GitHub repository.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n repoVisibility: inputProps.repoVisibility,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n autoInit: inputProps.autoInit,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n repoVisibility = 'private',\n deleteBranchOnMerge = false,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n token: providedToken,\n autoInit = undefined,\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 autoInit,\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","inputProps.autoInit","outputProps.remoteUrl","outputProps.repoContentsUrl","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics"],"mappings":";;;;;;;;;;;AAqCO,SAAS,6BAA6B,OAAA,EAG1C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AA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,CAAW;AAAA,QACrC,GAAA,EAAK,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC5C,IAAI,YAAY;AACd,UAAA,MAAM,UAAU,MAAMC,kDAAA;AAAA,YACpB,MAAA;AAAA,YACA,IAAA;AAAA,YACA,KAAA;AAAA,YACA,cAAA;AAAA,YACA,WAAA;AAAA,YACA,QAAA;AAAA,YACA,mBAAA;AAAA,YACA,gBAAA;AAAA,YACA,gBAAA;AAAA,YACA,sBAAA;AAAA,YACA,wBAAA;AAAA,YACA,gBAAA;AAAA,YACA,cAAA;AAAA,YACA,iBAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAA;AAAA,YACA,WAAA;AAAA,YACA,OAAA;AAAA,YACA,SAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAA;AAAA,YACA,OAAA;AAAA,YACA,iBAAA;AAAA,YACA,gBAAA;AAAA,YACA,SAAA;AAAA,YACA,GAAA,CAAI,MAAA;AAAA,YACJ;AAAA,WACF;AACA,UAAA,OAAO,OAAA,CAAQ,SAAA;AAAA,QACjB;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AAAA,IACnC;AAAA,GACD,CAAA;AACH;;;;"}
@@ -972,6 +972,21 @@ const examples = [
972
972
  }
973
973
  ]
974
974
  })
975
+ },
976
+ {
977
+ description: "Create a repository with an initial commit.",
978
+ example: yaml__default.default.stringify({
979
+ steps: [
980
+ {
981
+ action: "github:repo:create",
982
+ name: "Create a new GitHub repository with an initial (signed) commit containing a README",
983
+ input: {
984
+ repoUrl: "github.com?repo=repo&owner=owner",
985
+ autoInit: true
986
+ }
987
+ }
988
+ ]
989
+ })
975
990
  }
976
991
  ];
977
992