@backstage/plugin-scaffolder-backend-module-github 0.8.2-next.1 → 0.8.3-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.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/actions/gitHelpers.cjs.js.map +1 -1
  3. package/dist/actions/gitHubEnvironment.examples.cjs.js.map +1 -1
  4. package/dist/actions/github.cjs.js.map +1 -1
  5. package/dist/actions/github.examples.cjs.js.map +1 -1
  6. package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
  7. package/dist/actions/githubActionsDispatch.examples.cjs.js.map +1 -1
  8. package/dist/actions/githubAutolinks.cjs.js.map +1 -1
  9. package/dist/actions/githubAutolinks.examples.cjs.js.map +1 -1
  10. package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
  11. package/dist/actions/githubBranchProtection.examples.cjs.js.map +1 -1
  12. package/dist/actions/githubDeployKey.cjs.js.map +1 -1
  13. package/dist/actions/githubDeployKey.examples.cjs.js.map +1 -1
  14. package/dist/actions/githubEnvironment.cjs.js.map +1 -1
  15. package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
  16. package/dist/actions/githubIssuesLabel.examples.cjs.js.map +1 -1
  17. package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
  18. package/dist/actions/githubPagesEnable.examples.cjs.js.map +1 -1
  19. package/dist/actions/githubPullRequest.cjs.js.map +1 -1
  20. package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -1
  21. package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
  22. package/dist/actions/githubRepoCreate.examples.cjs.js.map +1 -1
  23. package/dist/actions/githubRepoPush.cjs.js.map +1 -1
  24. package/dist/actions/githubRepoPush.examples.cjs.js.map +1 -1
  25. package/dist/actions/githubWebhook.cjs.js.map +1 -1
  26. package/dist/actions/githubWebhook.examples.cjs.js.map +1 -1
  27. package/dist/actions/helpers.cjs.js.map +1 -1
  28. package/dist/actions/inputProperties.cjs.js.map +1 -1
  29. package/dist/actions/outputProperties.cjs.js.map +1 -1
  30. package/dist/autocomplete/autocomplete.cjs.js.map +1 -1
  31. package/dist/module.cjs.js.map +1 -1
  32. package/dist/util.cjs.js.map +1 -1
  33. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.8.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/integration@1.18.0-next.0
9
+ - @backstage/plugin-scaffolder-node@0.11.1-next.0
10
+ - @backstage/backend-plugin-api@1.4.3-next.0
11
+ - @backstage/plugin-catalog-node@1.18.1-next.0
12
+
13
+ ## 0.8.2
14
+
15
+ ### Patch Changes
16
+
17
+ - a22cce0: Fixed bug in the `customProperties` type which was preventing it being used to set a list of values against a key (e.g. for multi-select fields)
18
+ - Updated dependencies
19
+ - @backstage/plugin-scaffolder-node@0.11.0
20
+ - @backstage/plugin-catalog-node@1.18.0
21
+ - @backstage/backend-plugin-api@1.4.2
22
+
3
23
  ## 0.8.2-next.1
4
24
 
5
25
  ### Patch Changes
@@ -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,2BAA8B,GAAA,IAAA;AAAA,EAC9B,8BAAiC,GAAA,KAAA;AAAA,EACjC,uBAA0B,GAAA,KAAA;AAAA,EAC1B,aAAgB,GAAA,QAAA;AAAA,EAChB,aAAgB,GAAA,IAAA;AAAA,EAChB,mBAAsB,GAAA,KAAA;AAAA,EACtB,qBAAwB,GAAA,KAAA;AAAA,EACxB,qBAAwB,GAAA;AAC1B,CAA8C,KAAA;AAC5C,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAI,IAAA;AACF,MAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,sBAAuB,CAAA;AAAA,QAC7C,SAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQT,QAAA,EAAU,CAAC,mBAAmB;AAAA,SAChC;AAAA,QACA,KAAA;AAAA,QACA,IAAM,EAAA,QAAA;AAAA,QACN,MAAQ,EAAA,aAAA;AAAA,QACR,sBAAwB,EAAA;AAAA,U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AAQ,CAAA,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};\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;AAA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A,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;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"gitHubEnvironment.examples.cjs.js","sources":["../../src/actions/gitHubEnvironment.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Create a GitHub Environment (No Policies, No Variables, No Secrets)',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Protected Branch Policy',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Branch Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['main', '*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables and Secrets',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n key1: 'val1',\n key2: 'val2',\n },\n secrets: {\n secret1: 'supersecret1',\n secret2: 'supersecret2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n customTagPolicyNames: ['release/*/*', 'v*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Both Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['feature/*', 'hotfix/*'],\n customTagPolicyNames: ['release/*', 'v*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Full Configuration',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['dev/*', 'test/*'],\n customTagPolicyNames: ['v1.*', 'v2.*'],\n environmentVariables: {\n API_KEY: '123456789',\n NODE_ENV: 'production',\n },\n secrets: {\n DATABASE_URL: 'supersecretdatabaseurl',\n API_SECRET: 'supersecretapisecret',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Only Token Authentication',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with No Deployment Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: null,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Custom Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['release/*', 'hotfix/*'],\n customTagPolicyNames: ['v*', 'release-*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Environment Variables Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Deployment Secrets Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Deployment Branch Policy and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables, Secrets, and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Wait Timer',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n waitTimer: 1000,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Prevent Self Review',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n preventSelfReview: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n reviewers: ['group:default/team-a', 'user:default/johndoe'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA,SAAA;AAAA,YACN,sBAAwB,EAAA;AAAA,cACtB,kBAAoB,EAAA,IAAA;AAAA,cACpB,sBAAwB,EAAA;AAAA;AAC1B;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,yDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA,SAAA;AAAA,YACN,sBAAwB,EAAA;AAAA,cACtB,kBAAoB,EAAA,KAAA;AAAA,cACpB,sBAAwB,EAAA;AAAA,aAC1B;AAAA,YACA,uBAAA,EAAyB,CAAC,MAAA,EAAQ,OAAO;AAAA;AAC3C;AACF;AACF,KAC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,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA,SAAA;AAAA,YACN,SAAW,EAAA;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,sDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA,SAAA;AAAA,YACN,iBAAmB,EAAA;AAAA;AACrB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,4CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,2BAAA;AAAA,UACR,IAAM,EAAA,oBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,IAAM,EAAA,SAAA;AAAA,YACN,SAAA,EAAW,CAAC,sBAAA,EAAwB,sBAAsB;AAAA;AAC5D;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"gitHubEnvironment.examples.cjs.js","sources":["../../src/actions/gitHubEnvironment.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Create a GitHub Environment (No Policies, No Variables, No Secrets)',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Protected Branch Policy',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Branch Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['main', '*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables and Secrets',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n key1: 'val1',\n key2: 'val2',\n },\n secrets: {\n secret1: 'supersecret1',\n secret2: 'supersecret2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n customTagPolicyNames: ['release/*/*', 'v*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Both Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['feature/*', 'hotfix/*'],\n customTagPolicyNames: ['release/*', 'v*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Full Configuration',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['dev/*', 'test/*'],\n customTagPolicyNames: ['v1.*', 'v2.*'],\n environmentVariables: {\n API_KEY: '123456789',\n NODE_ENV: 'production',\n },\n secrets: {\n DATABASE_URL: 'supersecretdatabaseurl',\n API_SECRET: 'supersecretapisecret',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Only Token Authentication',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with No Deployment Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: null,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Custom Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['release/*', 'hotfix/*'],\n customTagPolicyNames: ['v*', 'release-*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Environment Variables Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Deployment Secrets Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Deployment Branch Policy and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables, Secrets, and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Wait Timer',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n waitTimer: 1000,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Prevent Self Review',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n preventSelfReview: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n reviewers: ['group:default/team-a', 'user:default/johndoe'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,sBAAA,EAAwB;AAAA,cACtB,kBAAA,EAAoB,IAAA;AAAA,cACpB,sBAAA,EAAwB;AAAA;AAC1B;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,yDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAA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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,EAA8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AA;AAAA,YACA,SAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAA;AAAA,YACA,OAAA;AAAA,YACA,iBAAA;AAAA,YACA,gBAAA;AAAA,YACA,SAAA;AAAA,YACA,GAAI,CAAA;AAAA,WACN;AAEA,UAAO,OAAA;AAAA,YACL,WAAW,OAAQ,CAAA,SAAA;AAAA,YACnB,eAAiB,EAAA,CAAA,EAAG,OAAQ,CAAA,QAAQ,SAAS,aAAa,CAAA;AAAA,WAC5D;AAAA;AACF,OACD,CAAA;AAED,MAAA,MAAM,eAAe,MAAMC,8BAAA;AAAA,QACzB,SAAA;AAAA,QACA,cAAe,CAAA,IAAA;AAAA,QACf,GAAI,CAAA,aAAA;AAAA,QACJ,IAAI,KAAM,CAAA,UAAA;AAAA,QACV,aAAA;AAAA,QACA,oBAAA;AAAA,QACA,oBAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA;AAAA,QACA,IAAA;AAAA,QACA,uBAAA;AAAA,QACA,2BAAA;AAAA,QACA,4BAAA;AAAA,QACA,YAAA;AAAA,QACA,2BAAA;AAAA,QACA,2BAAA;AAAA,QACA,8BAAA;AAAA,QACA,uBAAA;AAAA,QACA,MAAA;AAAA,QACA,GAAI,CAAA,MAAA;AAAA,QACJ,gBAAA;AAAA,QACA,aAAA;AAAA,QACA,cAAA;AAAA,QACA,mBAAA;AAAA,QACA,qBAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,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,OAAA,EAIvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAA,EAAQ,yBAAA,EAA0B,GAAI,OAAA;AAE5D,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,mFAAA;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AAA,YACA,GAAA,CAAI;AAAA,WACN;AAEA,UAAA,OAAO;AAAA,YACL,WAAW,OAAA,CAAQ,SAAA;AAAA,YACnB,eAAA,EAAiB,CAAA,EAAG,OAAA,CAAQ,QAAQ,SAAS,aAAa,CAAA;AAAA,WAC5D;AAAA,QACF;AAAA,OACD,CAAA;AAED,MAAA,MAAM,eAAe,MAAMC,8BAAA;AAAA,QACzB,SAAA;AAAA,QACA,cAAA,CAAe,IAAA;AAAA,QACf,GAAA,CAAI,aAAA;AAAA,QACJ,IAAI,KAAA,CAAM,UAAA;AAAA,QACV,aAAA;AAAA,QACA,oBAAA;AAAA,QACA,oBAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA;AAAA,QACA,IAAA;AAAA,QACA,uBAAA;AAAA,QACA,2BAAA;AAAA,QACA,4BAAA;AAAA,QACA,YAAA;AAAA,QACA,2BAAA;AAAA,QACA,2BAAA;AAAA,QACA,8BAAA;AAAA,QACA,uBAAA;AAAA,QACA,MAAA;AAAA,QACA,GAAA,CAAI,MAAA;AAAA,QACJ,gBAAA;AAAA,QACA,aAAA;AAAA,QACA,cAAA;AAAA,QACA,mBAAA;AAAA,QACA,qBAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,YAAA,EAAc,YAAA,EAAc,UAAU,CAAA;AACjD,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAA,GAAA,CAAI,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA,IAC/C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"github.examples.cjs.js","sources":["../../src/actions/github.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitHub repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitHub repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,WAAa,EAAA;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,6FAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,cAAgB,EAAA;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"github.examples.cjs.js","sources":["../../src/actions/github.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitHub repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitHub repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,6FAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -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 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,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,yBAAA;AAAA,IACJ,WACE,EAAA,+DAAA;AAAA,cACFC,uCAAA;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,UAAA,EAAY,CACV,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WAAa,EAAA;AAAA,SACd,CAAA;AAAA,QACH,eAAA,EAAiB,CACf,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH,CAA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A,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,OAAA,EAG/C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EACE,+DAAA;AAAA,cACFC,uCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,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B,KAAA,EAAO;AAAA,OACR,CAAA;AACD,MAAA,MAAM,MAAA,GAAS,IAAIC,eAAA,CAAQ;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,KAAK,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA,EAAI,IAAI,IAAI,UAAU,CAAA,CAAA;AAAA,QAC5D,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,sBAAA,CAAuB;AAAA,YAC/C,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAA,EAAa,UAAA;AAAA,YACb,GAAA,EAAK,eAAA;AAAA,YACL,MAAA,EAAQ;AAAA,WACT,CAAA;AAED,UAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,SAAA,EAAY,UAAU,CAAA,wBAAA,CAA0B,CAAA;AAAA,QAClE;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubActionsDispatch.examples.cjs.js","sources":["../../src/actions/githubActionsDispatch.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub Action Workflow Without Inputs.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Inputs',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow with inputs',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n workflowInputs: {\n input1: 'value1',\n input2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Custom Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow (custom token)',\n input: {\n repoUrl: 'github.com?repo=reponame&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'release-1.0',\n token: '${{ secrets.MY_CUSTOM_TOKEN }}',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,iCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,oCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,6CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA,MAAA;AAAA,YACjB,cAAgB,EAAA;AAAA,cACd,MAAQ,EAAA,QAAA;AAAA,cACR,MAAQ,EAAA;AAAA;AACV;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,gDAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,sCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA,aAAA;AAAA,YACjB,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubActionsDispatch.examples.cjs.js","sources":["../../src/actions/githubActionsDispatch.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub Action Workflow Without Inputs.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Inputs',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow with inputs',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n workflowInputs: {\n input1: 'value1',\n input2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Custom Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow (custom token)',\n input: {\n repoUrl: 'github.com?repo=reponame&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'release-1.0',\n token: '${{ secrets.MY_CUSTOM_TOKEN }}',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,iCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,oCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,6CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,MAAA;AAAA,YACjB,cAAA,EAAgB;AAAA,cACd,MAAA,EAAQ,QAAA;AAAA,cACR,MAAA,EAAQ;AAAA;AACV;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,gDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,sCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,aAAA;AAAA,YACjB,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -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 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,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A,GAAS,IAAIC,eAAQ,CAAA;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAI,CAAA;AAAA,OACV,CAAA;AAED,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,GAAK,EAAA,CAAA,iBAAA,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;;;;"}
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,4BAA4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;AAEA,MAAA,MAAM,cAAA,GAAiB,MAAMC,sBAAA,CAAkB;AAAA,QAC7C,YAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,mBAAA,EAAqB,yBAAA;AAAA,QACrB;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,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,iBAAA,EAAoB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACtC,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAe;AAAA,YACrC,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAA,EAAY,SAAA;AAAA,YACZ,YAAA,EAAc,WAAA;AAAA,YACd,eAAA,EAAiB;AAAA,WAClB,CAAA;AAED,UAAA,GAAA,CAAI,MAAA,CAAO,KAAK,CAAA,uCAAA,CAAyC,CAAA;AAAA,QAC3D;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubAutolinks.examples.cjs.js","sources":["../../src/actions/githubAutolinks.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub alphanumric autolink reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:autolinks:create',\n name: 'Create an autolink reference',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n keyPrefix: 'TICKET-',\n urlTemplate: 'https://example.com/TICKET?query=<num>',\n isAlphanumeric: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,8BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,SAAA;AAAA,YACX,WAAa,EAAA,wCAAA;AAAA,YACb,cAAgB,EAAA;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubAutolinks.examples.cjs.js","sources":["../../src/actions/githubAutolinks.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub alphanumric autolink reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:autolinks:create',\n name: 'Create an autolink reference',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n keyPrefix: 'TICKET-',\n urlTemplate: 'https://example.com/TICKET?query=<num>',\n isAlphanumeric: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,8BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,SAAA;AAAA,YACX,WAAA,EAAa,wCAAA;AAAA,YACb,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -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,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,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AAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACzC,IAAI,YAAY;AACd,UAAA,MAAM,UAAa,GAAA,MAAM,MAAO,CAAA,IAAA,CAAK,MAAM,GAAI,CAAA;AAAA,YAC7C,KAAA;AAAA,YACA;AAAA,WACD,CAAA;AACD,UAAA,OAAO,WAAW,IAAK,CAAA,cAAA;AAAA;AACzB,OACD,CAAA;AAED,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,GAAK,EAAA,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC9C,IAAI,YAAY;AACd,UAAA,MAAMC,oDAA0C,CAAA;AAAA,YAC9C,QAAU,EAAA,IAAA;AAAA,YACV,MAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAQ,GAAI,CAAA,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,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,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,E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["../../src/actions/githubBranchProtection.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: `GitHub Branch Protection for repository's default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection for a specific branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branch: 'my-awesome-branch',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required commit signing on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required linear history on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n requiredLinearHistory: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,CAAA,yDAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,iCAAA;AAAA,UACR,IAAM,EAAA,yBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,CAAA,+CAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,iCAAA;AAAA,UACR,IAAM,EAAA,yBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,MAAQ,EAAA;AAAA;AACV;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,iCAAA;AAAA,UACR,IAAM,EAAA,yBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,uBAAyB,EAAA,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAqB,EAAA,IAAA;AAAA,YACrB,uBAAyB,EAAA,IAAA;AAAA,YACzB,8BAAgC,EAAA,IAAA;AAAA,YAChC,qBAAuB,EAAA;AAAA;AACzB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,iCAAA;AAAA,UACR,IAAM,EAAA,yBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,uBAAyB,EAAA,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAqB,EAAA,IAAA;AAAA,YACrB,uBAAyB,EAAA,IAAA;AAAA,YACzB,8BAAgC,EAAA,IAAA;AAAA,YAChC,qBAAuB,EAAA,IAAA;AAAA,YACvB,qBAAuB,EAAA;AAAA;AACzB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubBranchProtection.examples.cjs.js","sources":["../../src/actions/githubBranchProtection.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: `GitHub Branch Protection for repository's default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection for a specific branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branch: 'my-awesome-branch',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required commit signing on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required linear history on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n requiredLinearHistory: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,CAAA,yDAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,+CAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,MAAA,EAAQ;AAAA;AACV;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,uBAAA,EAAyB,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAA,EAAqB,IAAA;AAAA,YACrB,uBAAA,EAAyB,IAAA;AAAA,YACzB,8BAAA,EAAgC,IAAA;AAAA,YAChC,qBAAA,EAAuB;AAAA;AACzB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,uBAAA,EAAyB,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAA,EAAqB,IAAA;AAAA,YACrB,uBAAA,EAAyB,IAAA;AAAA,YACzB,8BAAA,EAAgC,IAAA;AAAA,YAChC,qBAAA,EAAuB,IAAA;AAAA,YACvB,qBAAA,EAAuB;AAAA;AACzB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubDeployKey.cjs.js","sources":["../../src/actions/githubDeployKey.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 createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './githubDeployKey.examples';\n\n/**\n * Creates an `github:deployKey:create` Scaffolder action that creates a Deploy Key\n *\n * @public\n */\nexport function createGithubDeployKeyAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\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 publicKey: z =>\n z.string({\n description:\n 'Generated from `ssh-keygen`. Begins with `ssh-rsa`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`, `sk-ecdsa-sha2-nistp256@openssh.com`, or `sk-ssh-ed25519@openssh.com`.',\n }),\n privateKey: z =>\n z.string({\n description: 'SSH Private Key generated from `ssh-keygen`',\n }),\n deployKeyName: z =>\n z.string({\n description: `Name of the Deploy Key`,\n }),\n privateKeySecretName: z =>\n z\n .string({\n description:\n 'Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: `KEY_NAME_PRIVATE_KEY` where `KEY_NAME` is the name of the Deploy Key',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n privateKeySecretName: z =>\n z.string({\n description:\n 'The GitHub Action Repo Secret Name for the Private Key',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n publicKey,\n privateKey,\n deployKeyName,\n privateKeySecretName = `${deployKeyName\n .split(' ')\n .join('_')\n .toLocaleUpperCase('en-US')}_PRIVATE_KEY`,\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\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.deploy.key.${owner}.${repo}.${publicKey}`,\n fn: async () => {\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n },\n });\n\n const { key, keyId } = await ctx.checkpoint({\n key: `get.repo.public.key.${owner}.${repo}`,\n fn: async () => {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n return {\n key: publicKeyResponse.data.key,\n keyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n key,\n Sodium.base64_variants.ORIGINAL,\n );\n const binarySecret = Sodium.from_string(privateKey);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await ctx.checkpoint({\n key: `create.or.update.repo.secret.${owner}.${repo}.${keyId}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: keyId,\n });\n },\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","S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MAAO,CAAA,IAAA,CAAK,QAAQ,gBAAiB,CAAA;AAAA,YACnE,KAAA;AAAA,YACA;AAAA,WACD,CAAA;AACD,UAAO,OAAA;AAAA,YACL,GAAA,EAAK,kBAAkB,IAAK,CAAA,GAAA;AAAA,YAC5B,KAAA,EAAO,kBAAkB,IAAK,CAAA;AAAA,WAChC;AAAA;AACF,OACD,CAAA;AAED,MAAA,MAAMC,uBAAO,CAAA,KAAA;AACb,MAAA,MAAM,YAAYA,uBAAO,CAAA,WAAA;AAAA,QACvB,GAAA;AAAA,QACAA,wBAAO,eAAgB,CAAA;AAAA,OACzB;AACA,MAAM,MAAA,YAAA,GAAeA,uBAAO,CAAA,WAAA,CAAY,UAAU,CAAA;AAClD,MAAA,MAAM,wBAAwBA,uBAAO,CAAA,eAAA;AAAA,QACnC,YAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,MAAM,wBAAwBA,uBAAO,CAAA,SAAA;AAAA,QACnC,qBAAA;AAAA,QACAA,wBAAO,eAAgB,CAAA;AAAA,OACzB;AAEA,MAAA,MAAM,IAAI,UAAW,CAAA;AAAA,QACnB,KAAK,CAAgC,6BAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,IAAI,KAAK,CAAA,CAAA;AAAA,QAC3D,IAAI,YAAY;AACd,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,wBAAyB,CAAA;AAAA,YACjD,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,oBAAA;AAAA,YACb,eAAiB,EAAA,qBAAA;AAAA,YACjB,MAAQ,EAAA;AAAA,WACT,CAAA;AAAA;AACH,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,wBAAwB,oBAAoB,CAAA;AAAA;AACzD,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubDeployKey.cjs.js","sources":["../../src/actions/githubDeployKey.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 createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './githubDeployKey.examples';\n\n/**\n * Creates an `github:deployKey:create` Scaffolder action that creates a Deploy Key\n *\n * @public\n */\nexport function createGithubDeployKeyAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\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 publicKey: z =>\n z.string({\n description:\n 'Generated from `ssh-keygen`. Begins with `ssh-rsa`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`, `sk-ecdsa-sha2-nistp256@openssh.com`, or `sk-ssh-ed25519@openssh.com`.',\n }),\n privateKey: z =>\n z.string({\n description: 'SSH Private Key generated from `ssh-keygen`',\n }),\n deployKeyName: z =>\n z.string({\n description: `Name of the Deploy Key`,\n }),\n privateKeySecretName: z =>\n z\n .string({\n description:\n 'Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: `KEY_NAME_PRIVATE_KEY` where `KEY_NAME` is the name of the Deploy Key',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n privateKeySecretName: z =>\n z.string({\n description:\n 'The GitHub Action Repo Secret Name for the Private Key',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n publicKey,\n privateKey,\n deployKeyName,\n privateKeySecretName = `${deployKeyName\n .split(' ')\n .join('_')\n .toLocaleUpperCase('en-US')}_PRIVATE_KEY`,\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\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.deploy.key.${owner}.${repo}.${publicKey}`,\n fn: async () => {\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n },\n });\n\n const { key, keyId } = await ctx.checkpoint({\n key: `get.repo.public.key.${owner}.${repo}`,\n fn: async () => {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n return {\n key: publicKeyResponse.data.key,\n keyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n key,\n Sodium.base64_variants.ORIGINAL,\n );\n const binarySecret = Sodium.from_string(privateKey);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await ctx.checkpoint({\n key: `create.or.update.repo.secret.${owner}.${repo}.${keyId}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: keyId,\n });\n },\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAgCO,SAAS,4BAA4B,OAAA,EAEzC;AACD,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAGzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EAAa,gCAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sBAAA;AAAA,SACd,CAAA;AAAA,QACH,oBAAA,EAAsB,CAAA,CAAA,KACpB,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA;AAAS,OAChB;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,oBAAA,EAAsB,CAAA,CAAA,KACpB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH;AAAA;AACL,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB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AAAA,IACzD;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubDeployKey.examples.cjs.js","sources":["../../src/actions/githubDeployKey.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Example 1: Create and store a Deploy Key',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:deployKey:create',\n name: 'Create and store a Deploy Key',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n publicKey: 'pubkey',\n privateKey: 'privkey',\n deployKeyName: 'Push Tags',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,+BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,wCAAA;AAAA,YACT,SAAW,EAAA,QAAA;AAAA,YACX,UAAY,EAAA,SAAA;AAAA,YACZ,aAAe,EAAA;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubDeployKey.examples.cjs.js","sources":["../../src/actions/githubDeployKey.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Example 1: Create and store a Deploy Key',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:deployKey:create',\n name: 'Create and store a Deploy Key',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n publicKey: 'pubkey',\n privateKey: 'privkey',\n deployKeyName: 'Push Tags',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,+BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,SAAA,EAAW,QAAA;AAAA,YACX,UAAA,EAAY,SAAA;AAAA,YACZ,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;;;"}